Resources
As you work on your final project, here are some helpful resources.
References
These extensive references contain all the information needed to do a ton of cool stuff with Python:
Code Examples
If you need to remember how to do anything, check out these code examples.
Input & Output
Take input from the user with input
, and produce output with print
.
# Get input, store in a variable
name = input("What is your name?")
# Print a message using the name given
print("Hi, " + name)
Conditionals
Change program flow depending on values with if
/else
statements.
# Setup
temp = 50
if temp > 65:
# If temp is greater than 65...
print("Wear a T-shirt")
else:
# If temp is less than or equal to 65...
print("Wear a sweatshirt")
Functions
Teach Python how to do new things by defining and calling functions.
# Define a function
def show_bunny():
print(" /\/\ ")
print(">( ^.^)<")
print(" ( ) ")
# Call a function
show_bunny()
Loops
Run code repeatedly with for
loops.
# Loop 25 times
for x in range(25):
print(25)