Variables, Data Types, Math
Lists and Strings
Conditionals and If-Else
For Loops
While Loops
100

What are the 5 data types we've learned in this class? Give an example of each

int - 5

float - 5.0

boolean - True

string - "Hi"

list - ['I', 'love', 'girls', 'who', 'code']

100

In Python, what is the number that list and string indexing starts at?

0

100

What do these evaluate to (True or False)?

True and False

True or False

not True

False

True

False

100

What is the python syntax to write a for loop that loops through every item in the list my_list

for item in my_list:

100

What is the python syntax to write a while loop that prints “Remember an umbrella!” when it is raining?

raining = True

while raining:

   print("Remember an umbrella!")

200

How do I assign the value 10 to the variable called num_coins?

num_coins = 10

200

What code would get the letter t from the variable fav_fruit?

fav_fruit = 'watermelon'

fav_fruit[2]

200

What does this evaluate to (True or False)?

x = True

y = False

z = True

(x and y) or (not y and z)

True

200

What is the value of ice_cream during the third time through the loop?

What gets printed during the third time through the loop?

flavors = ['Vanilla', 'Chocolate', 'Mint']

for ice_cream in flavors:

   print(ice_cream.lower())

'Mint'

mint

200

How many times do we go through this while loop? What gets printed?

count = 0

while count < 5:

    count += 1

print(count)

5 times

5

300

From before, I have

num_coins = 10

How do I update the variable num_coins to have 4 less than its previous value?

num_coins = num_coins - 4

300

How do I use list splicing to a get a list with only Wonder Woman and Black Panther?

superheroes = ["Spider-Man", "Wonder Woman", "Black Panther", "Batman"]


superheroes[1:3]

300

What will get printed?

temperature = 53

if temperature < 60:

    print("Staying in the cave and roasting marshmallows!")

else:

    print("Time to fly through the skies!")

Staying in the cave and roasting marshmallows!

300

What does the following code print?

for x in range(420, 425):

   print(2)

2

2

2

2

2

300

What will get printed?

x = 1

total = 0

while x <= 5:

    total += x

    x += 1

    print(total)

1

3

6

10

15

400

What's the code to ask the user "What is your favorite sport?" and store their answer in a variable called fav_sport

Hint: use input functions

fav_sport = input("What is your favorite sport?")

400

my_string = "Hi my name is KIRAN"

How do I print my_string with the lower case letters upper case and the upper case letters lower case (I want to swap cases)?

Hint: Google string methods

print(my_string.swapcase())

400

What will get printed?

temperature = 53

if temperature < 40:

    print("Staying in the cave and roasting marshmallows!")

elif (temperature >= 40) and (temperature < 60):

    print("A bit chilly, but time to fly through the skies!")

else:

    print("Perfect weather for a dragon picnic!")

A bit chilly, but time to fly through the skies!

400

How do I write a for loop to print out 2 plus every element in the list nums?

nums = range(0, 20)

for i in nums:

   print(2+i)

400

Write a while loop that prints "Hello!" 4 times.

Hint: Start with a variable count = 0

count = 0

while count < 4:

    print("Hello!")

    count += 1

500

What is the python syntax to store your three favorite snacks—"chips", "cookies", and "popcorn"—in one variable called snacks

snacks = ["chips", "cookies", "popcorn"]

500

How do I add "Iron Man" to my list superheroes?

Hint: Google list methods

superheroes.append("Iron Man")

500

What will get printed?

temperature = 53

humidity = 75

if temperature < 60:

    if humidity > 70:

        print("Chilly but time to fly through the skies with an umbrella!")

    else:

        print("Chilly but time to fly through the skies!")

else:

    print("Perfect weather for a dragon picnic!")

Chilly but time to fly through the skies with an umbrella!

500

Using a for loop, how do I print out the sum of all the elements in the list nums?

Hint: I need to declare an element before the for loop header

nums = range(0, 20)

sum = 0

for current_num in nums:

   sum = sum + i

print(sum)

500

You set your alarm so you can snooze 3 times before you have to get up.

Write a while loop that checks if you can snooze your alarm and prints “WAKE UPPPP” when you can’t snooze it anymore.

Hints: (1) You need a variable to track how many times you’ve snoozed. What should happen to that number every time you snooze?"


(2) While loops keep running as long as a condition is true... what’s the condition for being allowed to snooze?"

snoozes_left = 3

while snoozes_left > 0:

    print("Snoozing...")

    snoozes_left -= 1 

print("WAKE UPPPP!")