You've learned this already. โ
Click here to view the next lesson.
Chapter 22 - Appendix C: Python Cheat Sheet
Basic Python Syntax
- Print Function
print("Hello, World!")- Variable Assignment
x = 5
y = "Hello, World!"- Comments
# This is a single line comment
"""
This is a
multi-line comment
"""- Conditional Statements
if x > y:
print("x is greater than y")
elif x < y:
print("x is less than y")
else:
print("x is equal to y")- Loops
for i in range(5):
print(i)
while x < 10:
print(x)
x += 1- Functions
def my_function():
print("Hello from a function")Basic Python Syntax
- Print Function
print("Hello, World!")- Variable Assignment
x = 5
y = "Hello, World!"- Comments
# This is a single line comment
"""
This is a
multi-line comment
"""- Conditional Statements
if x > y:
print("x is greater than y")
elif x < y:
print("x is less than y")
else:
print("x is equal to y")- Loops
for i in range(5):
print(i)
while x < 10:
print(x)
x += 1- Functions
def my_function():
print("Hello from a function")Basic Python Syntax
- Print Function
print("Hello, World!")- Variable Assignment
x = 5
y = "Hello, World!"- Comments
# This is a single line comment
"""
This is a
multi-line comment
"""- Conditional Statements
if x > y:
print("x is greater than y")
elif x < y:
print("x is less than y")
else:
print("x is equal to y")- Loops
for i in range(5):
print(i)
while x < 10:
print(x)
x += 1- Functions
def my_function():
print("Hello from a function")Basic Python Syntax
- Print Function
print("Hello, World!")- Variable Assignment
x = 5
y = "Hello, World!"- Comments
# This is a single line comment
"""
This is a
multi-line comment
"""- Conditional Statements
if x > y:
print("x is greater than y")
elif x < y:
print("x is less than y")
else:
print("x is equal to y")- Loops
for i in range(5):
print(i)
while x < 10:
print(x)
x += 1- Functions
def my_function():
print("Hello from a function")
