THIS command can be used to get information from the user
input()
randint(1, 10) generates random integers between one and THIS
10
fruits = ['banana', 'apple', 'grape']
THIS is fruits[2]
grape
THIS keyword begins a function definition
def
THIS variable type, named after an English mathematician, is used to express True or False
Boolean variables
var = True or False;
THIS is the value of var
TRUE
Use THIS loop to repeat code a specific number of times (often used with lists or strings)
for loop
THIS is one benefit of using functions
Shorter development time
Simpler iteration and testing of sub-components of code
Less duplication of code
Programming solutions that are easier to maintain
x = 5
y = 9
x = x + y
x = 8
THIS is the value of x
8
Use THIS loop to check a condition before repeating code
while loop
THIS mode is used to open a file and at text from the beginning
'w' or write
THIS command inserts represents a new line in a string or print statement
\n
THIS operator is used to check if two values are NOT equal
!=
Fill in THIS to print each letter in the string 'phrase'
phrase = "Hello"
for x in phrase:
 print(THIS)
x or f"{x}"
THIS is the keyword used to send information back from a function to the main code
return
THIS command forces the computer to exit the loop or branching structure at that point
break
x = False
y = False
if x and y:
print('Option 1')
elif x or y:
print('Option 2')
else:
print('Option 3')
THIS prints on the screen
Option 3
for x in range(5):
print(f"{x}")
The code prints THIS
0
1
2
3
4
def mystery(filename):
with (filename, 'r') open as file:
content = file.readlines()
data = []
for line in content:
data.append(int(line))
return data
the function does THIS
takes a file name as a parameter, opens and reads all information from the file to a list, converts each item in the list to an integer, and returns the list of integers