Learn Python fundamentals with hands-on examples and clear explanations.
Python is a popular, high-level, interpreted programming language known for its simplicity and readability.
print('Hello, World!')
Prints 'Hello, World!' to the console.
Variables in Python do not need explicit declaration to reserve memory space. The declaration happens automatically when you assign a value to a variable.
x = 5 # Integer
y = 3.14 # Float
name = 'Alice' # String
is_active = True # Boolean
Examples of different data types in Python.
Python uses indentation to define blocks of code. Control flow statements like if, for, and while are used to control the execution of code.
# If statement
x = 10
if x > 5:
print('x is greater than 5')
# For loop
for i in range(3):
print(i)
# While loop
count = 0
while count < 3:
print(count)
count += 1
Basic control flow examples in Python.