CSC111 Exercises with IF statements 2014
Contents
Source
# if_tests.py
# D. Thiebaut
# A collection of if/else statements.
# Figure out what gets printed!
def f1():
a = 3
b = 5
c = 10
if a < b:
print "statement 1"
else:
if a < c:
print "statement 2"
else:
if b < c:
print "statement 3"
print "f1 done!"
def f2():
a = 30
b = 5
c = 10
if a < b:
print "statement 1"
else:
if a < c:
print "statement 2"
else:
if b < c:
print "statement 3"
print "f2 done!"
def f3():
a = 30
b = 50
c = 10
if a < b:
print "statement 1"
else:
if a < c:
print "statement 2"
else:
if b < c:
print "statement 3"
print "f3 done!"
def f4():
a = 30
b = 5
c = 10
if a < b < c:
print "statement 1"
else:
if a < c < b:
print "statement 2"
else:
print "statement 3"
print "statement 4"
print "f4 done!"
def f5():
a = 30
b = 50
c = 10
if a < b < c:
print "statement 1"
else:
if a < c < b:
print "statement 2"
else:
print "statement 3"
print "statement 4"
print "f5 done!"
def f6():
a = 3
b = 5
c = 1
if a < b < c:
print "statement 1"
else:
if a < c < b:
print "statement 2"
else:
print "statement 3"
print "statement 4"
print "f6 done!"