For Loops
String functions
String indexing and splicing
While Loops
Arrays
100

Count to 10 using a for loop

for i in range(1,11):

    write(i)

100

What does this write?

var teacher = "Mr. Kleinscroth"

write(teacher.to_lower())

"mr. kleinscroth'

100

var word = "GODOT". What is word[1]?

"O"

100

Describe how a while loop works

While a condition is true, continue
100

Create an empty array (list)

var array = []

200

What does this write?

for i in range(2, 10, 3):

    write(str(i))

2, 5, 8

200

What does "Minecraft".length() return?

9

200

What does this write?

var word = "GODOT"

for letter in word:

    write(letter)

G

O

D

O

T

200

How do you stop this while loop?

var is_alive = true

var health = 100

var score = 0

while is_alive:

    score = score + 1

    ...

    health = 0

is_alive = false

200

What does fruits[3] write? ["Banana", "Apple", "Orange", "Pineapple", "Cherry"]

"Pineapple"

300

Why does this code fail?

var list = ["Minecraft", "Roblox", "CS2", "Flappy bird"]

for i in range(list.size()):

    if print(i)


IndexError index out of range as size returns the number of items in the list but the highest index of the list is list.size()-1.

300

What does this write?

var fruits = "apple,banana,cherry"

write(fruits.split(",")[1])

 

"banana"

300

What does "GODOT".substr(1, 3) return?

"ODO"

300

Why does this loop never end?

var count = 0

while count < 5:

    write(str(count))

Count never changes so count will always be less than 5

300

What happens when you run write(city[4])? city = ["Toronto", "New York", "Tokyo", "Paris"]

Error (bonus points for IndexError, index out of range)

400

How many times does "hi" get written? 

for i in range(3):

    for j in range(4):

        write("hi")

12

400

What does this return? 

"I like cats".replace("cats", "dogs").to_upper()

"I LIKE DOGS"

400

Write code that writes "Hello" backwards ("olleH")

write(word.reverse())

var word = "GODOT"

var result = ""

for i in range(word.length() - 1, -1, -1):

    result += word[i]

write(result)


400

What does this write?

var x = 1

while x < 20:

    x = x * 2

write(str(x))

32

400

var list = ["John", "Jane", "David", "Luke"]

for name in list:

    write(name+"! " + str(randi_range(1,10)))

John! random number from 1-10

Jane! random number from 1-10

David! random number from 1-10

Luke! random number from 1-10

500

Write a for loop that adds up every number from 1 to 50 and writes the total

var total = 0

for i in range(1, 101):

    total += i

write(str(total))

500

How would you evaluate the user's answer as no for "Nah", "no", "No", "noooo ", "nah", " nope"?

Starting code: 

var answer = input()



Many answers:

    var answer = input()

    if answer.to_upper().strip_edges().begins_with("N"):

        write("No")

    elif answer.to_upper().strip_edges().begins_with("Y"):

        write("Yes")

    else:

        write("Invalid input")

500

Write one line of code that writes the last letter without counting the letters yourself.

E.g. var name = "Tab" -> writes "b"

var name = "Kleinscroth" -> writes "h"

write(name[name.length() - 1])

write(name[-1])

500

Write a while loop that prints out every letter in "Godot"

var word = "Godot"

var i = 0

while i < word.length()-1:

    write(word[i])

500

var list = ["Canada", "US", "Congo", "Sweden"]

list.append("Gabon")

new_list = list[3]

write(list[4])

"Gabon"

M
e
n
u