PYTHON PROGRAMMING 10

 

separator-blank.png

 

QUIZ REVIEW

 

What will each of the following programs output to screen? 

 

If a program will not output anything, then simply write nothing.  Careful, some programs are tricky.

 

PROGRAM

OUTPUT

a)

def fun(num):
    return num * num
 
print(fun(4))

a)

b)

a = "Wonder"
b = "Woman"
print(b + a)

b)

c)

a = "3"
b = "5"
print(a + b)

c)

d)

coco = 4
bobo = 7
print(coco > bobo)

d)

e)

x = 8
if (x == 8):
    print("A")
print("C")

e)

f)

x = 7
if (x != 7):
    print("A")
else:
    print("E")
print("C")

f)

g)

val = 7
print(val >= 0 and val <= 10)

g)

h)

a = 77
if a < 100:
    print("A")
elif a < 80:
    print("B")
else:
    print("C")

h)

i)

for x in range(1, 4):
       print(x)

 

i)

j)

def cool(x):
    return x + x
 
def dude(n):
    return n + 1
 
print(dude(cool(3)))

j)

k)

val = -2
print(val >= 0 or val <= 10)

k)

l)

woot = True
print(not woot)

l)

m)

for x in range(1, 4):
       print("A")

m)

n)

def cool(x):
    return x + x
 
def dude(n):
    return n + 1
 
print(cool(dude(3)))

n)

o)

def cool(x):
    return x + x
 
def dude(n):
    return n + 1
 
b = cool(2) + dude(4)
print(b)

o)

p)

def cool(x):
    return x + x
 
def dude(n):
    return n + 1

p)

q)

a = 2
b = 3
c = 4
d = a + b * c
print(d)

q)

 

This review doesn’t include randint or input.

 

separator-blank.png