Previous Lecture lec14 Next Lecture

lec14, Thu 11/14

Exam 2 Review

Code for the practice exam

Q2.1 What is printed after this code executes?

x=2
while(x>0):
     if (x%2 == 0):
         print(x)
     x=x-1
print(x)

Q2.2 How would the output change if we modify the above code as follows?

x=3
while(x>0):
    if (x%2 == 0):
        print(x)
x=x-1
print(x)
def is_string1( text ):
    return (text == str)

def is_string2( text ):
    print (text == str)

text1 = is_string1("Hi")
text2 = is_string1(42)
text3 = is_string2("Bye")
text4 = is_string2(42)
print ("Compare text variables")
print (text1, " & ", text2)
print (text3, " & ", text4)