Nothing Special   »   [go: up one dir, main page]

Graded Quiz Unit 6 PDF

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

5/24/2019 Graded Quiz Unit 6

CS 1101 Programming Fundamentals - Term 4, 2018-2019


Home ► My courses ► CS 1101 - AY2019-T4 ► 16 May - 22 May ► Graded Quiz Unit 6

Started on Tuesday, 21 May 2019, 8:27 PM


State Finished
Completed on Tuesday, 21 May 2019, 8:46 PM
Time taken 18 mins 50 secs
Marks 20.00/20.00
Grade 100.00 out of 100.00

Question 1 Match the following terms and de nitions


Correct

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

The rst part of a compound statement begins with header


a 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=1879933&cmid=172064 1/10
5/24/2019 Graded Quiz Unit 6
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'.

Question 3 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 4 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

https://my.uopeople.edu/mod/quiz/review.php?attempt=1879933&cmid=172064 2/10
5/24/2019 Graded Quiz Unit 6
Question 5 With built in functions, it is generally acceptable to take a "Leap of Faith".
Correct

Mark 1.00 out of Select one:


1.00 True

False

The correct answer is 'True'.

Question 6
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 7 The statements inside of a Python loop are known as the ____ of the loop.
Correct

Mark 1.00 out of Select one:


1.00 a. body

b. expression

c. counter

d. block

The correct answer is: body

https://my.uopeople.edu/mod/quiz/review.php?attempt=1879933&cmid=172064 3/10
5/24/2019 Graded Quiz Unit 6
Question 8 What output will the following Python commands produce?
Correct

Mark 1.00 out of >>> percentage = oat ( 60 * 100) / 55


1.00 >>> print (percentage)

Select one:
a. percentage

b. 109

c. 109.0909090909091

d. 109.0

The correct answer is: 109.0909090909091

Question 9 Expressions evaluate to either True or False. What will be the output of the
Correct following Python 3 program?
Mark 1.00 out of
1.00 if "Ni!":
    print ('We are the Knights who say, "Ni!"')
else:
    print ("Stop it! No more of this!")

Select one:
a. Stop it!

b. We are the Knights who say, "Ni!"

c. Stop it! No more of this!"

d. No output will be produced

The correct answer is: We are the Knights who say, "Ni!"

https://my.uopeople.edu/mod/quiz/review.php?attempt=1879933&cmid=172064 4/10
5/24/2019 Graded Quiz Unit 6
Question 10 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=1879933&cmid=172064 5/10
5/24/2019 Graded Quiz Unit 6
Question 11 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

Question 12
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'.

https://my.uopeople.edu/mod/quiz/review.php?attempt=1879933&cmid=172064 6/10
5/24/2019 Graded Quiz Unit 6
Question 13 A loop where the terminating condition is never achieved is called  _______.
Correct

Mark 1.00 out of Select one:


1.00 a. an in nite loop

b. a universal loop

c. a while loop

d. a for .. ever loop

The correct answer is: an in nite loop

Question 14 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=1879933&cmid=172064 7/10
5/24/2019 Graded Quiz Unit 6
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

Question 16 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

https://my.uopeople.edu/mod/quiz/review.php?attempt=1879933&cmid=172064 8/10
5/24/2019 Graded Quiz Unit 6
Question 17 A development approach that is intended to avoid a lot of debugging by
Correct only adding and testing small amounts of code at a time is called:
Mark 1.00 out of
1.00 Select one:
a. structured development

b. incremental development

c. unit testing

d. Systems development life cycle

The correct answer is: incremental development

Question 18 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

https://my.uopeople.edu/mod/quiz/review.php?attempt=1879933&cmid=172064 9/10
5/24/2019 Graded Quiz Unit 6
Question 19
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 20 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'.

◄ Self-Quiz Unit 6

Jump to...

Unit 5 Programming Assignment Sample Solution ►

https://my.uopeople.edu/mod/quiz/review.php?attempt=1879933&cmid=172064 10/10

You might also like