back

Python Cheat Sheet

Contents

  1. Variables and Data Types
  2. Input and Output

Variables and Data Types

name = "John"   # string  ->  str
age = 30        # number  ->  int
weight = 63.5   # number  ->  float
married = True  # Boolean -> bool

Input and Output

# Read Input from terminal window
name = input("Enter Name")

# Write name to terminal window
print(name)     

Arithmetic Operators

x = 10
y = 3
z = x + y   # addition -> 13
z = x - y   # subtraction -> 7
z = x * y   # multiplication -> 30
z = x / y   # true division -> 3.3333
z = x // y  # floor division -> 3
z = x ** y  # exponent -> 1000
z = x % y   # modulo division -> 1