Python is a beginner-friendly language. Print your first program:
print("Hello, World!")
Variables store data. No need to declare type.
name = "Alice" # string
age = 20 # integer
height = 5.5 # float
is_student = True # boolean
Make decisions in code.
if age >= 18:
print("Adult")
else:
print("Minor")
Repeat code. For and While loops.
for i in range(5):
print(i)
count = 0
while count < 3:
print(count)
count += 1
Lists are mutable collections.
fruits = ["apple", "banana", "cherry"]
fruits.append("orange")
print(fruits[0]) # apple
Key-value pairs.
student = {"name": "Bob", "age": 22}
print(student["name"])
Reusable code blocks.
def greet(name):
return f"Hello, {name}!"
print(greet("Alice"))