Programming Building Blocks
Find the Error
Predict the Output
Strings
Random
100

This is what you use to store data or information 

What is a variable? 

100

age = 16

print("You are " + age + " years old.")


What is a TypeError? 

100

x = 5

print(x+3)

What is 8?

100

This is the result of the following: 

print("Hi" + "class")

What is "Hiclass"?

100

The four different variables we have talked about 

integers, floats, booleans, and strings

200

This type of statement allows your program to choose between different paths based on a condition.

What is an if statement? 

200

x=5 

if x =2:

    print("This number is 2.")

else: 

    print("This number is not 2.")

What is a missing equal sign? 

200

for i in range(3):

    print(i)

What is 0, 1, and 2

200

This is the result of the following:

print("ha" * 2)

haha

200

These are used to document your functions and provide those reading your code with explanations as to how your code works. 

What are comments?

300

This keyword lets you exit out of a loop early

What is a break statement?

300

positive = 10

while positive > 0:

    print("This number is positive")


What is an infinite loop? 

300

for i in range(5, 1, -1):

    if i % 2 == 0:

        print(i)


What is 4 and 2?

300

name = "Jordan"

print(name[1])

What is "o"?

300

Difference between using a set of if statements vs elif statements.

A set of if statements run regardless of the previous condition. A set of elif statements only run if previous condition was not true.

400

You would use this kind of loop to repeatedly ask a user for an input until they type in “quit”.

What is a while loop?
400

def add(a, b): 

    return a + b


add(2)

What is missing a parameter? 

400

for i in range(5):

    if i % 2 == 0:

        continue

     print(i)


What is 1 and 3?

400
my_string = "hello class" 


my_string = my_string[:5] + ":)"

print(my_string)

What is "hello :)"

400

These are the 3 different logical operators. 

What are AND, OR, NOT? 

500

This pair of keywords is used to handle errors and prevent your program from crashing.

What are try and except? 

500

def square(n):

    result = n * n

print(square(5))


What is a missing return statement? 

500

x = 3

def update(x):

    x = x + 2

    return x

update(x)

print(x)


What is 3?

500

text = "random stuff"

other_text = "days"

print(text[:100] + other_text[-2])

What is "random stuff y"

500

The difference between interpreted language and a compiled language.

A compiled language is converted into machine code so that the processor can execute it. An interpreted language is a language in which the implementations execute instructions directly without earlier compiling a program into machine language