Code icon

The App is Under a Quick Maintenance

We apologize for the inconvenience. Please come back later

Menu iconMenu iconPython & SQL Bible
Python & SQL Bible

Chapter 22 - Appendix C: Python Cheat Sheet

Basic Python Syntax

  1. Print Function
print("Hello, World!")
  1. Variable Assignment
x = 5
y = "Hello, World!"
  1. Comments
# This is a single line comment
"""
This is a
multi-line comment
"""
  1. 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")
  1. Loops
for i in range(5):
    print(i)

while x < 10:
    print(x)
    x += 1
  1. Functions
def my_function():
    print("Hello from a function")

Basic Python Syntax

  1. Print Function
print("Hello, World!")
  1. Variable Assignment
x = 5
y = "Hello, World!"
  1. Comments
# This is a single line comment
"""
This is a
multi-line comment
"""
  1. 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")
  1. Loops
for i in range(5):
    print(i)

while x < 10:
    print(x)
    x += 1
  1. Functions
def my_function():
    print("Hello from a function")

Basic Python Syntax

  1. Print Function
print("Hello, World!")
  1. Variable Assignment
x = 5
y = "Hello, World!"
  1. Comments
# This is a single line comment
"""
This is a
multi-line comment
"""
  1. 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")
  1. Loops
for i in range(5):
    print(i)

while x < 10:
    print(x)
    x += 1
  1. Functions
def my_function():
    print("Hello from a function")

Basic Python Syntax

  1. Print Function
print("Hello, World!")
  1. Variable Assignment
x = 5
y = "Hello, World!"
  1. Comments
# This is a single line comment
"""
This is a
multi-line comment
"""
  1. 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")
  1. Loops
for i in range(5):
    print(i)

while x < 10:
    print(x)
    x += 1
  1. Functions
def my_function():
    print("Hello from a function")