Programming Language
Python is a high-level, interpreted programming language known for its simplicity, readability, and versatility. Created by Guido van Rossum and first released in 1991, Python has grown to become one of the most popular programming languages worldwide.
Python emphasizes code readability with its notable use of significant whitespace. Its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages like C++ or Java.
# This is a comment in Python def hello_world(): """This is a docstring that describes the function""" name = "World" # String variable age = 25 # Integer variable pi = 3.14159 # Float variable is_active = True # Boolean variable # Print with formatted string (f-string in Python 3.6+) print(f"Hello, {name}! You are {age} years old.") return is_active # Call the function result = hello_world() print(f"The result is: {result}")
# Lists - ordered, mutable collection fruits = ["apple", "banana", "cherry"] fruits.append("orange") # Add to the list # Dictionaries - key-value pairs person = { "name": "Alice", "age": 30, "is_student": False } # Tuples - ordered, immutable collection coordinates = (10.5, 20.8) # Sets - unordered collection of unique items unique_numbers = {1, 2, 3, 1, 4} # Will contain {1, 2, 3, 4}
# Conditional statements x = 10 if x > 10: print("x is greater than 10") elif x == 10: print("x is equal to 10") else: print("x is less than 10") # Loops # For loop for fruit in fruits: print(fruit) # While loop count = 0 while count < 5: print(count) count += 1
Python is incredibly versatile and is used in a wide variety of applications:
Python has evolved significantly since its inception:
Python 2 reached end-of-life on January 1, 2020. All new Python code should use Python 3.
Here are some excellent resources for learning Python:
Technologies often used with Python or alternative options: