Cheatsheet Python Beginners PDF
Cheatsheet Python Beginners PDF
pi = 3.14
Reverse a list Sort a list
L.reverse() L.sort()
Strings
Conditional Statements
Creating strings with single or double quotes
If statements
greeting = "Hello"
name = ' World'
if x > 5:
print(greeting + name)
print("x is greater than 5")
# prints "Hello Worlds"
If else statements
Concatenation String contains another string
if age < 12:
msg = "Hello, " + "World!" "ap" in "apple" # True
print("child")
print(msg) "z" in "apple" # False
else:
print("adult")
String formatting
Functions
Function with no parameters Function with multiple parameters
w ww.afternerd.com