Graded Quiz Unit 6 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

21/8/2019 Graded Quiz Unit 6

CS 1101 Programming Fundamentals - Term 5, 2018-2019


Home ► My courses ► CS 1101 - AY2019-T5 ► 25 July - 31 July ► Graded Quiz Unit 6

Started on Wednesday, 31 July 2019, 9:29 PM


State Finished
Completed on Wednesday, 31 July 2019, 9:54 PM
Time taken 24 mins 31 secs
Marks 19.00/20.00
Grade 95.00 out of 100.00

Question 1 What is the output of the following Python program?


Correct
pi = oat(3.14159)
Mark 1.00 out of
1.00
print (pi)

Select one:
a. 3

b. 3.0

c. 3.14159

d. 0

Your answer is correct.

The correct answer is: 3.14159

Question 2 Functions can only return boolean expressions.


Correct

Mark 1.00 out of Select one:


1.00 True

False

The correct answer is 'False'.

https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 1/12
Question 3
21/8/2019 Graded Quiz Unit 6

What output will the following interactive Python statements produce?


Correct
>>> n = 2
Mark 1.00 out of
1.00
>>> n += 5
>>> n

Select one:
a. 7

b. 5

c. 0

d. None

Your answer is correct.


The correct answer is: 7

Question 4 What output will the following Python 3 program produce?


Correct

Mark 1.00 out of n = 10


1.00 while n != 1:
    print(n,)
    if n % 2 == 0: # n is even
    n=n/2
    else: # n is odd
    n=n*3+1

Select one:
a. 10 5 16 8 4 2

b. None an error will be displayed

c. 8 4 2

d. 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2

The correct answer is: 10 5 16 8 4 2

https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 2/12
Question 5
21/8/2019 Graded Quiz Unit 6
What output will the following Python 3 program produce?
Correct

Mark 1.00 out of x=5


1.00 if x % 2 == 0:
    print (x)
else:
    print (x, x%2)

Select one:
a. 5

b. 5 1

c. 2

d. 5 0

The correct answer is: 5 1

Question 6 What output will the following Python program produce?


Correct

Mark 1.00 out of def area(l, w):


1.00     temp = l * w
    return temp
l = 4.0
w = 3.25
x = area(l, w)
if ( x ):
    print (x)

Select one:
a. 13.0

b. 0

c. Expression does not evaluate to boolean true

d. 13

The correct answer is: 13.0

https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 3/12
Question 7
21/8/2019 Graded Quiz Unit 6
What is the return type of the Python function shown below?
Correct
 
Mark 1.00 out of
1.00
def is_divisible(x, y):

return (x % y) == 0

Select one:
a. int

b. oat

c. bool

d. string

e. NoneType

Your answer is correct.

The correct answer is: bool

Question 8 What is the output of the Python code below?


Correct
s = "help"
Mark 1.00 out of for letter in s[1:]:
1.00
      last = letter
      break
print(last)

Select one:
a. h

b. e

c. !

d. p

e. l

Your answer is correct.

The correct answer is: e

https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 4/12
Question 9
21/8/2019 Graded Quiz Unit 6
What is the value of the variable index after the Python code below is
Correct executed?
Mark 1.00 out of  
1.00
word = 'bAnana'

index = word.find('a')

Select one:
a. 3

b. 1

c. 2

d. 5

e. 0

Your answer is correct.

The correct answer is: 3

Question 10 What output will the following Python program produce?


Correct

Mark 1.00 out of n = 10000


1.00 count = 0
while n:
    count = count + 1
    n = n / 10
    n=int(n)
print(count)

Select one:
a. 5

b. 0

c. 10000

d. 1000

The correct answer is: 5


https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 5/12
Question 11
21/8/2019 Graded Quiz Unit 6
Repeated execution of a set of programming statements is called
Correct repetitive execution.
Mark 1.00 out of
1.00 Select one:
True

False

The correct answer is 'False'.

Question 12 What output will the following Python 3 script produce?


Correct

Mark 1.00 out of def function2(param):


1.00     print (param, param)
def function1(part1, part2):
    cat = part1 + part2
    function2(cat)
chant1 = "See You "
chant2 = "See Me "
function1(chant1, chant2)

Select one:
a. See You See Me

b. See You See Me See You See Me

c. See Me See Me See You See You

d. None it would generate an error

The correct answer is: See You See Me See You See Me

https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 6/12
Question 13
21/8/2019 Graded Quiz Unit 6
Match the following terms and de nitions
Correct

Mark 1.00 out of The order in which statements are executed during a flow of execution
1.00 program run.

The rst part of a compound statement begins with a header


keyword and ends with a colon ( : )

A statement that executes a function. It consists of


function call
the name of the function followed by a list of
arguments enclosed in parentheses.

A variable de ned inside a function that can only be local variable


used inside its function.

A graphical representation of functions, their stack diagram


variables, and the values to which they refer.

Your answer is correct.


The correct answer is: The order in which statements are executed during
a program run. → ow of execution, The rst part of a compound
statement begins with a keyword and ends with a colon ( : ) → header, A
statement that executes a function. It consists of the name of the function
followed by a list of arguments enclosed in parentheses. → function call, A
variable de ned inside a function that can only be used inside its function.
→ local variable, A graphical representation of functions, their variables,
and the values to which they refer. → stack diagram

https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 7/12
Question 14
21/8/2019 Graded Quiz Unit 6
The following Python 3 code is an example of what principle?
Correct

Mark 1.00 out of bruce = 5


1.00 print (bruce,)
bruce = 7
print (bruce)

Select one:
a. Reassignment

b. An Iteration or loop structure

c. A logical operator

d. A conditional expression

The correct answer is: Reassignment

Question 15 What is the return type of the Python function shown below?
Correct
isinstance(10.001, float)
Mark 1.00 out of
1.00
Select one:
a. int

b. oat

c. bool

d. string

e. NoneType

Your answer is correct.


The correct answer is: bool

https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 8/12
Question 16
21/8/2019 Graded Quiz Unit 6
A stack diagram shows the value of each variable and the function to which
Correct each variable belongs.
Mark 1.00 out of
1.00 Select one:
True

False

The correct answer is 'True'.

Question 17 What is the output of the following Python 3 statements?


Correct

Mark 1.00 out of x=1


1.00 y=2
if x == y:
    print (x, "and", y, "are equal")
else:
    if x < y:
        print (x, "is less than", y)
    else:
        print (x, "is greater than", y)

Select one:
a. 1 and 2 are equal

b. 1 is less than 2

c. 1 is greater than 2

d. 2 is greater than 1

The correct answer is: 1 is less than 2

https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 9/12
Question 18
21/8/2019 Graded Quiz Unit 6

What is the output of the following Python program?


Correct
pi = int(3.14159)
Mark 1.00 out of
1.00
print (pi)

Select one:
a. 3

b. 3.0

c. 3.14159

d. 0

Your answer is correct.


The correct answer is: 3

https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 10/12
Question 19
21/8/2019 Graded Quiz Unit 6

Will the Python code below print something? And will it terminate?
Incorrect
def print_n(s, n):
Mark 0.00 out of
1.00
     if n > 0:
          print(s)
          print_n(s, n-1)
     return n
n=3
while print_n("hi", n):
     print_n("there!", n)
     n = 0
____

Select one:
a. no and no

b. yes and no

c. no and yes

d. yes and yes

e. syntax error

Your answer is incorrect.


The correct answer is: yes and yes

Question 20 The Python 3 program below prints the number 3.


Correct
s = "Python3"
Mark 1.00 out of
1.00 print(s[len(s)])

Select one:
True

False

The correct answer is 'False'.

◄ Self-Quiz Unit 6
https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 11/12
21/8/2019 Graded Quiz Unit 6
Jump to...

Unit 5 Programming Assignment Sample Solution ►

https://my.uopeople.edu/mod/quiz/review.php?attempt=2030572&cmid=177096 12/12

You might also like