21. What is the radius attribute after the following code block is run?

RedCircle=Circle(10,'red')

RedCircle.radius=1

  • 10
  • 1
  • ‘red’

22. What is the radius attribute after the following code block is run?

BlueCircle=Circle(10,'blue')

BlueCircle.add_radius(20)

  • 10
  • 20
  • 30

Module 3 Graded Quiz

23. What is the output of the following code?

x="Go"

if(x=="Go"):

print('Go ')

else:

print('Stop')

print('Mike')

  • Go Mike
  • Mike
  • Stop Mike

24. What is the result of the following lines of code?

x=1
x>-5

  • True
  • False

25. What is the output of the following few lines of code?

x=5
while(x!=2):
print(x)
x=x-1

  • 5

    4

    3

  • 5

    4

    3

    2

  • the program will never leave the loop

26. What is the result of running the following lines of code ?

class Points(object):
def __init__(self,x,y):

self.x=x
self.y=y

def print_point(self):

print('x=',self.x,' y=',self.y)

p1=Points("A","B")
p1.print_point()

  • x= A
  • y= B
  • x= A y= B

27. What is the output of the following few lines of code?

for i,x in enumerate(['A','B','C']):
print(i,2*x)

  • 0 AA

    1 BB

    2 CC

  • 0 A

    1 B

    2 C

  • 0 A

    2 B

    4 C

28. What is the result of running the following lines of code ?

class Points(object):
def __init__(self,x,y):

self.x=x
self.y=y

def print_point(self):

print('x=',self.x,' y=',self.y)

p2=Points(1,2)

p2.x=2

p2.print_point()

  • x=2 y=2
  • x=1 y=2
  • x=1 y=1

Shuffle Q/A 3

29. Consider the function step, when will the function return a value of 1?

def step(x):
if x>0:
y=1
else:
y=0
return y

  • if x is larger than 0
  • if x is equal to or less then zero
  • if x is less than zero

30. What is the output of the following lines of code?

a=1

def do(x):
a=100
return(x+a)

print(do(1))

  • 2
  • 101
  • 102

Leave a Reply