fbpx

Python Code Templates (PREVIEW)

print(context)

print("Hello, world!")

Input statements (cont.)

input(question)

input("What's your name?")

Concatenation

string + variable + string

"Hi " + name + ", how are you?"

If statements

if...

Get the Python Cram Kit to see!

Else if statements

elif...

Get the Python Cram Kit to see!

Else statements

else...

Get the Python Cram Kit to see!

While loops

while...

Get the Python Cram Kit to see!

For loops

for...

Get the Python Cram Kit to see!


Input statement variations

...with integers

int(input(question))

int(input("What's your favorite number?"))

...with floats

float(input(question))

float(input("How much does gas cost per gallon?"))


While loop variations

...with flag variables

while...

Get the Python Cram Kit to see!

...with a counter variable

while...

Get the Python Cram Kit to see!


For loop variations

...with multiple arrays

for...

Get the Python Cram Kit to see!


Concatenation variations

...with integers or floats

string +...

Get the Python Cram Kit to see!