PyGame Guide/Python Crash Course

A basic program edit

A simple Hello World program:


print("Hello World")

Variables edit

Variables in Python are dynamically typed. This means that a variable may hold either a number, string, or any object.

variably = 40
variably = 40.9
variably = "fourty point nine"

print(variably)
# Based on the assignment above, this will print "fourty point nine"

Input and output edit

If statements edit

if True:
  print("This will always execute")

if 6 > 5:
  print("6 is, in fact, greater than 5")

variably = False
if variably:
  print("variably is True")
else:
  print("variably is False")

letter = "a"
if letter == "a":
  print("got option A")
elif letter == "b":
  print("got option B")
elif letter == "c":
  print("got option C")
else:
  print("got unknown option")

While loops edit

For loops edit

Functions edit

Classes edit

Inheritance edit