Key Terms
Code Tracing 1
Code Tracing 2
Writing Code
100

means 'else if'

elif

100

number = int(5)

number2 = number + 5

print(number2)


10

100

counter = int(20)

counter = counter + 10

counter = counter - 5

counter = counter + 20

print(counter)

45

100

ask for a users age

age = int(input("what is your age: "))

200

repeats code based on a sequence

for loop

200

print(“why did the chicken cross the road?”)

print(“to get to the other side”

syntax error

200

name = “Single ladies”

Song = name + “ by Beyonce”

n/a

200

use a for loop to count to 10

for i in range(11):

    print(i)

300

Causes a while loop to end

break statement

300

number1 = int(12)

number2 = int(12)

if number1 <= number2:

    print("that’s great")

else:

    print("that’s sad")

that's great

300

sunny = True

cloudy = False

laundryday = sunny and cloudy

print(laundryday)

laundryday = sunny or cloudy

print(laundryday)


False

True

300

add 1 to a counter everytime while loop goes around. Once the counter gets to 5, break. 

counter = 0

while True:

    counter = counter + 1

    print(counter)

    if counter ==5:

        break




400

Repeated execution of one or more statements in a program

Iteration

400

i = 1
while i < 6:
  print(i)
  i += 1

1

2

3

4

5

400

num = 5

num2 = 50

while num <= num2:

    num = num + 5

    print("valid")

    break

valid
400

using an if statement, print "it's hot" if the user enters the temperature as greater than 20 degrees. If less than 20 degrees, print 'its not hot'

temp = int(input("what is the temperature"))

if temp > 20:

    print("it's hot")

else:

    print("it's not hot")

500

a series of elements

sequence

500

for i in range(6):

    print(i)


0

1

2

3

4

5

500

for ele in range(len("Carleton")):

    print(ele)

print("next part")

0

1

2

3

4

5

6

7

next part

500

In a while loop, ask user for city names. If the amount of letters is greater than 5, print valid. If less than 5, print invalid and break.

longstr = ""

while True:

    text = input('enter a city name')

    num_letters = len(text)

    if num_letters > 5:

        print("valid")

    else:

        print("invalid")

        break