Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Cs 9 Reviews Quiz

Download as pdf or txt
Download as pdf or txt
You are on page 1of 87
At a glance
Powered by AI
The review quiz tests the student's knowledge of all materials learned in the course and helps guide them in thoroughly reviewing topics and adequately preparing for the final exam.

The review quiz will test the student's knowledge of all materials learned in this course. The results of this quiz will not count towards the student's final grade, but will help guide them in more thoroughly reviewing necessary topics and adequately preparing for the Final Exam.

The review quiz covers all topics learned throughout the entire course.

 Navigation

Home
Dashboard
Site pages
Raymond Enokela
My courses
CS 1101 - AY2021-T1
Participants
Badges
Home
Competencies
Grades
General
Home  My courses  CS 1101 - AY2021-T1  Final Exam (Days 1 - 4)  Review Quiz
3 September - 9
September
Review
10 SeptemberQuiz
- 16
September
17 September - 23
The Review Quiz will test your knowledge of all materials learned in this course. The results of this quiz will
September
not count towards your
24 September - 30 nal grade, but will help guide you in more thoroughly reviewing necessary topics
and adequately
September preparing for the Final Exam.
1 October - 7 October
8 October - 14 October
This quiz opened at Thursday, 22 October 2020, 12:05 AM
15 October - 21 October
22 October - 28 October
This quiz will close on Sunday, 1 November 2020, 11:55 PM.
Final Exam (Days 1 - 4)
Learning Guide Unit 9 Grading method: Highest grade

Review Quiz
Final Exam
Summary
Media Gallery of your previous attempts
UNIV 1001 - AY2021-T1
Attempt State Marks / 30.00 Grade / 100.00 Review

Finished
1 18.75 62.50 Review
Submitted Tuesday, 27 October 2020, 12:14 PM

Finished
2 13.13 43.78 Review
Submitted Friday, 30 October 2020, 9:21 AM

Finished
3 9.57 31.89 Review
Submitted Friday, 30 October 2020, 9:27 AM

Finished
4 10.00 33.33 Review
Submitted Friday, 30 October 2020, 9:32 AM

Finished
5 11.25 37.50 Review
Submitted Friday, 30 October 2020, 9:38 AM

/
 Navigation
Highest grade: 62.50 / 100.00.
Home
Dashboard
Site pages Re-attempt quiz
My courses
CS 1101 - AY2021-T1
Learning Guide Unit 9
◄Participants
Badges
Jump to...
Competencies
Grades
Final Exam ►
General

3 September -9
UoPeople Clock (GMT-5)
September
10 September - 16
All activities close on Wednesdays at 11:55 PM, except for Learning Journals/Portfolios which close
September
on
17Thursdays
September at-11:55
23 PM always following this clock.
September
Sat, Oct 31, 2020
24 September
8:53 am - 30
September
1 October - 7 October
8 October - 14 October
Disclaimer Regarding Use of Course Material  - Terms of Use
15 October - 21 October
22 October
University - 28 People
of the Octoberis a 501(c)(3) not for pro t organization. Contributions are tax deductible to the
extent permitted by law.
Final Exam (Days 1 - 4)
Copyright
Learning Guide Unit 9 © University of the People 2020. All rights reserved.

Review Quiz     
Reset userFinal
tour Exam
on this page
Media Gallery
UNIV 1001 - AY2021-T1

/
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  Final Exam (Days 1 - 4)  Review Quiz

Started on Friday, 30 October 2020, 9:33 AM


State Finished
Completed on Friday, 30 October 2020, 9:38 AM
Time taken 4 mins 45 secs
Marks 11.25/30.00
Grade 37.50 out of 100.00

Question 1 Incorrect Mark 0.00 out of 1.00

Which of the following types are allowed for Python dictionary keys?

Select one:

a. dictionary

b. list

c. list of dictionaries

d. tuple

e. All of the above

Your answer is incorrect.

The correct answer is: tuple

/
Question 2 Partially correct Mark 0.25 out of 1.00

Match concepts with their de nition!

Any one of the languages that people have designed for speci c
formal language
purposes, such as representing mathematical ideas or computer
programs; all programming languages are this kind of languages.

syntax error
Any one of the languages that people speak that evolved naturally.

An error that does not occur until the program has started to execute syntax error

but that prevents the program from continuing.

An error in a program that makes it do something other than what natural language

the programmer intended.

syntax error
The meaning of a program.

semantic error
The structure of a program.

An error in a program that makes it impossible to parse — and natural language

therefore impossible to interpret.

One of the basic elements of the syntactic structure of a program, token

analogous to a word in a natural language.

The correct answer is: Any one of the languages that people have designed for speci c
purposes, such as representing mathematical ideas or computer programs; all programming
languages are this kind of languages. → formal language, Any one of the languages that
people speak that evolved naturally. → natural language, An error that does not occur until
the program has started to execute but that prevents the program from continuing. →
runtime error, An error in a program that makes it do something other than what the
programmer intended. → semantic error, The meaning of a program. → semantics, The
structure of a program. → syntax, An error in a program that makes it impossible to parse —
and therefore impossible to interpret. → syntax error, One of the basic elements of the
syntactic structure of a program, analogous to a word in a natural language. → token

/
Question 3 Correct Mark 1.00 out of 1.00

What is Python’s response to the command: type(0.123)

Select one:

a. <class ' oat'>

b. <class 'bool'>

c. SyntaxError: invalid syntax

d. <class 'int'>

e. <class 'str'>

Your answer is correct.

The correct answer is: <class ' oat'>

Question 4 Incorrect Mark 0.00 out of 1.00

Which one of the following Python expressions generates a syntax error?

Select one:

a. 8 ^ 2

b. 8 ** 2

c. 8 +- 2

d. 8 += 2

e. 8 -+ 2

Your answer is incorrect.

The correct answer is: 8 += 2

/
Question 5 Incorrect Mark 0.00 out of 1.00

Consider the following Python program.

n = open('words.txt')
for line in n:
    word = line.strip()
    print(word)

What is line?

Select one:

a. A le object

b. A list of characters

c. A list of words

d. A string that may have a newline

e. A string with no newline

Your answer is incorrect.

The correct answer is: A string that may have a newline

/
Question 6 Correct Mark 1.00 out of 1.00

What output will the following Python script produce?

def function2(param):
    print (param, param)

def function1(part1, part2):


    cat = part1 + part2
    function2(cat)

chant1 = "See Me "


chant2 = "See You "
function1(chant1, chant2)

Select one:

a. See You See Me

b. See Me See You See Me See You

c. See Me See Me See You See You

d. None it would generate an error

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

/
Question 7 Incorrect Mark 0.00 out of 1.00

Which one of the following Python expressions has the value 64?

Select one:

a. 8 ^ 2

b. 8 ** 2

c. 8 +- 2

d. 8 += 2

e. 8 -+ 2

Your answer is incorrect.

The correct answer is: 8 ** 2

Question 8 Incorrect Mark 0.00 out of 1.00

: To create a new object that has the same value as an existing object is know as
creating an alias.

Select one:

True

False

The correct answer is 'False'.

/
Question 9 Incorrect Mark 0.00 out of 1.00

What is the output of the following Python statements?

def recurse(a):
    if (a == 0):
        print(a)
    else:
        recurse(a) 

recurse(1)

Select one:

a. 0

b. 1

c. no output

d. RuntimeError: maximum recursion depth exceeded

Your answer is incorrect.

The correct answer is: RuntimeError: maximum recursion depth exceeded

Question 10 Incorrect Mark 0.00 out of 1.00

What is the output of the following statements?

pi = int(3.14159)
print (pi)

Select one:

a. 3

b. 3.0

c. 3.14159

d. 0

The correct answer is: 3

/
Question 11 Incorrect Mark 0.00 out of 1.00

What does function subroutine do?

def subroutine( n ):
  while n > 0:
      print (n,)
      n -= 1

Select one:

a. Counts from 10 down to 0 and displays each number

b. Counts from n down to 1 and displays each number

c. Calculates the sum of n numbers greater than 0

d. Calculates the mean of n

The correct answer is: Counts from n down to 1 and displays each number

/
Question 12 Incorrect Mark 0.00 out of 1.00

What will the output of this python program be?

def test_function( length, width, height):


    print ("the area of the box is ",length*width*height)
    return length*width*height

l = 12.5
w=5
h=2
test_function(l, w, h)

Select one:

a. The area of the box is 125

b. The area of the box is 125.0

c. The area of the box is 120

d. 125.0

The correct answer is: The area of the box is 125.0

/
Question 13 Correct Mark 1.00 out of 1.00

What will the contents of mylist be after the following code has been executed?

>>> mylist = [1, 4, 2, 3]


>>> mylist.append(5)

Select one:

a. [1, 4, 2, 3, 5]

b. [5, 1, 4, 2, 3]

c. [null]

d. [1, 4, 2, 3]

The correct answer is: [1, 4, 2, 3, 5]

Question 14 Correct Mark 1.00 out of 1.00

Learning to debug can be frustrating, but it is a valuable skill that is useful for many
activities beyond programming.

Select one:

True

False

The correct answer is 'True'.

/
Question 15 Incorrect Mark 0.00 out of 1.00

String objects are modi ed with string slices.

Select one:

True

False

The correct answer is 'False'.

Question 16 Incorrect Mark 0.00 out of 1.00

What output will the following python commands produce:

x=1
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

/
Question 17 Incorrect Mark 0.00 out of 1.00

What is the output of the following Python program?

mylist = ["now", "four", "is", "score", "the", "and seven", "time", "years", "for"]
print(" ".join(mylist[1::2]))

Select one:

a. now is the time

b. now is the time for

c. four score and seven years

d. now four is score the and seven time years for

Your answer is incorrect.

The correct answer is: four score and seven years

/
Question 18 Incorrect Mark 0.00 out of 1.00

What output will the following python commands produce:

n = 10000
count = 0
while n:
    count = count + 1
    n = n // 10

print (count)

Select one:

a. 5

b. 0

c. 10000

d. 1000

The correct answer is: 5

/
Question 19 Incorrect Mark 0.00 out of 1.00

Assume that d is a Python dictionary. What does the following Python code produce?

d.items()

Select one:

a. a histogram

b. an inverted dictionary

c. a list of tuples

d. a lookup

e. a reverse lookup

Your answer is incorrect.

The correct answer is: a list of tuples

Question 20 Correct Mark 1.00 out of 1.00

The elements of a list are immutable.

Select one:

True

False

The correct answer is 'False'.

/
Question 21 Incorrect Mark 0.00 out of 1.00

What is the output of the Python code below?

my_list = [3, 2, 1]
print(my_list.sort())

Select one:

a. 0

b. {1, 2, 3}

c. None

d. syntax error

e. [1, 2, 3]

Your answer is incorrect.

The correct answer is: None

/
Question 22 Correct Mark 1.00 out of 1.00

What is the output of the following Python program?

mylist = [ [2,4,1], [1,2,3], [2,3,5] ]


total = 0
for sublist in mylist:
    total += sum(sublist)
print(total) 

Select one:

a. 14

b. 23

c. 0

d. 13

Your answer is correct.

The correct answer is: 23

/
Question 23 Correct Mark 1.00 out of 1.00

What output will the following python commands produce:

x=5
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 24 Correct Mark 1.00 out of 1.00

What output will the following code produce?

n = 10
while n != 1:
    print (n,end=' ')
    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 25 Correct Mark 1.00 out of 1.00

What is Python’s response to the command: type(123)

Select one:

a. <class ' oat'>

b. <class 'bool'>

c. SyntaxError: invalid syntax

d. <class 'int'>

e. <class 'str'>

Your answer is correct.

The correct answer is: <class 'int'>

/
Question 26 Correct Mark 1.00 out of 1.00

What output will the following Python 3 program produce?

x=5
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 27 Incorrect Mark 0.00 out of 1.00

Consider the following Python program.

n = open('words.txt')
for line in n:
    word = line.strip()
    print(word)

What is n?

Select one:

a. A le object

b. A list of characters

c. A list of words

d. A string that may have a newline

e. A string with no newline

Your answer is incorrect.

The correct answer is: A le object

/
Question 28 Incorrect Mark 0.00 out of 1.00

Given the following code, what will the output be?

import string

index = "Ability is a poor man's wealth". nd("w")


print(index)

Select one:

a. 24

b. 0

c. 23

d. -1

The correct answer is: 24

Question 29 Correct Mark 1.00 out of 1.00

What is the output of the following statements?

pi = oat(3.14159)
print (pi)

Select one:

a. 3

b. 3.0

c. 3.14159

d. 0

The correct answer is: 3.14159

/
Question 30 Incorrect Mark 0.00 out of 1.00

A loop where the terminating condition is never achieved is called an _______

Select one:

a. in nite loop

b. universal loop

c. while loop

d. for .. ever loop

The correct answer is: in nite loop

◄ Learning Guide Unit 9

Jump to...

Final Exam ►

/
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  Final Exam (Days 1 - 4)  Review Quiz

Started on Friday, 30 October 2020, 9:15 AM


State Finished
Completed on Friday, 30 October 2020, 9:21 AM
Time taken 6 mins 21 secs
Marks 13.13/30.00
Grade 43.78 out of 100.00

Question 1 Incorrect Mark 0.00 out of 1.00

 In Python, a list of characters is the same as a string.

Select one:

True

False

The correct answer is 'False'.

/
Question 2 Correct Mark 1.00 out of 1.00

What output will the following code produce?

mylist = [ [2,4,1], [1,2,3], [2,3,5] ]


a=0
b=0
total = 0
while a <= 2:
    while b < 2:
        total += mylist[a][b]
        b += 1
    a += 1
    b = 0 
print (total)

Select one:

a. 14

b. 23

c. 0

d. 13

The correct answer is: 14

/
Question 3 Correct Mark 1.00 out of 1.00

What will the contents of mylist be after the following code has been executed?

>>> mylist = [1, 4, 2, 3]


>>> mylist.append(5)

Select one:

a. [1, 4, 2, 3, 5]

b. [5, 1, 4, 2, 3]

c. [null]

d. [1, 4, 2, 3]

The correct answer is: [1, 4, 2, 3, 5]

/
Question 4 Incorrect Mark 0.00 out of 1.00

Assume that d is a Python dictionary. What does the following Python code produce?

result = dict()
for key in d:
    val = d[key]
    if val not in inverse:
        result[val] = [key]
    else:
        result[val].append(key)

Select one:

a. a histogram

b. an inverted dictionary

c. a list of tuples

d. a lookup

e. a reverse lookup

Your answer is incorrect.

The correct answer is: an inverted dictionary

/
Question 5 Incorrect Mark 0.00 out of 1.00

Assume that d is a Python dictionary. What does the following Python code produce?

result = dict()
for key in d:
   val = d[key]
    if val not in result:
        result[val] = [key]
    else:
        result[val].append(key)

Select one:

a. a histogram

b. an inverted dictionary

c. a list of tuples

d. a lookup

e. a reverse lookup

Your answer is incorrect.

The correct answer is: an inverted dictionary

Question 6 Correct Mark 1.00 out of 1.00

Learning to debug can be frustrating, but it is a valuable skill that is useful for many
activities beyond programming.

Select one:

True

False

The correct answer is 'True'.

/
Question 7 Correct Mark 1.00 out of 1.00

A loop where the terminating condition is never achieved is called an _______

Select one:

a. in nite loop

b. universal loop

c. while loop

d. for .. ever loop

The correct answer is: in nite loop

/
Question 8 Partially correct Mark 0.13 out of 1.00

Match concepts with their de nition.

syntax
An error in a program.

The process of nding and removing any of the three kinds of syntax

programming errors.

Any one of the languages that people have designed for speci c
debugging
purposes, such as representing mathematical ideas or computer
programs; all programming languages are this kind of languages.

A programming language like Python that is designed to be easy syntax

for humans to read and write.

interpreter
A program that reads another program and executes it.

A programming language that is designed to be easy for a


interpreter
computer to execute; also called machine language or assembly
language.

program
Any one of the languages that people speak that evolved naturally.

problem solving
To examine a program and analyse the syntactic structure.

A property of a program that can run on more than one kind of script

computer.

An instruction that causes the Python interpreter to display a value natural language

on the screen.

The process of formulating a problem, nding a solution, and natural language

expressing the solution.

a sequence of instructions that speci es to a computer actions and parse

computations to be performed.

natural language
A program stored in a le (usually one that will be interpreted).

/
One of the basic elements of the syntactic structure of a program, token

analogous to a word in a natural language.

problem solving
The structure of a program.

The correct answer is: An error in a program. → bug, The process of nding and removing
any of the three kinds of programming errors. → debugging, Any one of the languages that
people have designed for speci c purposes, such as representing mathematical ideas or
computer programs; all programming languages are this kind of languages. → formal
language, A programming language like Python that is designed to be easy for humans to
read and write. → high-level language, A program that reads another program and executes
it. → interpreter, A programming language that is designed to be easy for a computer to
execute; also called machine language or assembly language. → low-level language, Any one
of the languages that people speak that evolved naturally. → natural language, To examine a
program and analyse the syntactic structure. → parse, A property of a program that can run
on more than one kind of computer. → portability, An instruction that causes the Python
interpreter to display a value on the screen. → print statement, The process of formulating a
problem, nding a solution, and expressing the solution. → problem solving, a sequence of
instructions that speci es to a computer actions and computations to be performed. →
program, A program stored in a le (usually one that will be interpreted). → script, One of the
basic elements of the syntactic structure of a program, analogous to a word in a natural
language. → token, The structure of a program. → syntax

/
Question 9 Correct Mark 1.00 out of 1.00

Given the following code, what will the output be?

mylist = ["now", "four", "is", "score", "the", "and seven", "time", "years", "for"]
a=0
while a < 7:
    print (mylist[a],)
    a += 2

Select one:

a. now is the time

b. now is the time for

c. for score and seven years

d. now four is score the and seven time years for

The correct answer is: now is the time

/
Question 10 Incorrect Mark 0.00 out of 1.00

What output will the following python commands produce:

x=5
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 11 Incorrect Mark 0.00 out of 1.00

What output will the following python commands produce:

n = 10000
count = 0
while n:
    count = count + 1
    n = n // 10

print (count)

Select one:

a. 5

b. 0

c. 10000

d. 1000

The correct answer is: 5

/
Question 12 Correct Mark 1.00 out of 1.00

What output will the following python commands produce:

x=1
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

/
Question 13 Incorrect Mark 0.00 out of 1.00

What is the output of the following Python program?

mylist = ["now", "four", "is", "score", "the", "and seven", "time", "years", "for"]
print(" ".join(mylist[1::2]))

Select one:

a. now is the time

b. now is the time for

c. four score and seven years

d. now four is score the and seven time years for

Your answer is incorrect.

The correct answer is: four score and seven years

Question 14 Incorrect Mark 0.00 out of 1.00

Given the following code, what will the output be?

import string

index = "Ability is a poor man's wealth". nd("w")


print(index)

Select one:

a. 24

b. 0

c. 23

d. -1

The correct answer is: 24

/
Question 15 Incorrect Mark 0.00 out of 1.00

Which one of the following Python expressions has the value 10?

Select one:

a. 8 ^ 2

b. 8 ** 2

c. 8 +- 2

d. 8 += 2

e. 8 -+ 2

Your answer is incorrect.

The correct answer is: 8 ^ 2

Question 16 Incorrect Mark 0.00 out of 1.00

What is the output of the following statements?

pi = int(3.14159)
print (pi)

Select one:

a. 3

b. 3.0

c. 3.14159

d. 0

The correct answer is: 3

/
Question 17 Incorrect Mark 0.00 out of 1.00

What is the output of the Python code below?

my_list = [3, 2, 1]
print(my_list.sort())

Select one:

a. 0

b. {1, 2, 3}

c. None

d. syntax error

e. [1, 2, 3]

Your answer is incorrect.

The correct answer is: None

/
Question 18 Incorrect Mark 0.00 out of 1.00

Consider the following Python program.

n = open('words.txt')
for line in n:
    word = line.strip()
    print(word)

What is word?

Select one:

a. A le object

b. A list of characters

c. A list of words

d. A string that may have a newline

e. A string with no newline

Your answer is incorrect.

The correct answer is: A string with no newline

Question 19 Correct Mark 1.00 out of 1.00

Given a Python dictionary d and a value v, it is e cient to nd the corresponding


key: d[k] = v.

Select one:

True

False

The correct answer is 'False'.

/
Question 20 Incorrect Mark 0.00 out of 1.00

: To create a new object that has the same value as an existing object is know as
creating an alias.

Select one:

True

False

The correct answer is 'False'.

Question 21 Incorrect Mark 0.00 out of 1.00

A variable that has a data type of "str" cannot be part of a compound data type

Select one:

True

False

The correct answer is 'False'.

/
Question 22 Incorrect Mark 0.00 out of 1.00

Which one of the following Python expressions generates a syntax error?

Select one:

a. 8 ^ 2

b. 8 ** 2

c. 8 +- 2

d. 8 += 2

e. 8 -+ 2

Your answer is incorrect.

The correct answer is: 8 += 2

Question 23 Correct Mark 1.00 out of 1.00

What is Python’s response to the command: type(0.123)

Select one:

a. <class ' oat'>

b. <class 'bool'>

c. SyntaxError: invalid syntax

d. <class 'int'>

e. <class 'str'>

Your answer is correct.

The correct answer is: <class ' oat'>

/
Question 24 Correct Mark 1.00 out of 1.00

What is the output of the following statements?

pi = oat(3.14159)
print (pi)

Select one:

a. 3

b. 3.0

c. 3.14159

d. 0

The correct answer is: 3.14159

Question 25 Correct Mark 1.00 out of 1.00

The Python expression 'Unit 6'[-1] has value '6'.

Select one:

True

False

The correct answer is 'True'.

/
Question 26 Correct Mark 1.00 out of 1.00

What does function subroutine do?

def subroutine( n ):
  while n > 0:
      print (n,)
      n -= 1

Select one:

a. Counts from 10 down to 0 and displays each number

b. Counts from n down to 1 and displays each number

c. Calculates the sum of n numbers greater than 0

d. Calculates the mean of n

The correct answer is: Counts from n down to 1 and displays each number

Question 27 Incorrect Mark 0.00 out of 1.00

String objects are modi ed with string slices.

Select one:

True

False

The correct answer is 'False'.

/
Question 28 Correct Mark 1.00 out of 1.00

Which one of the following Python expressions has the value 64?

Select one:

a. 8 ^ 2

b. 8 ** 2

c. 8 +- 2

d. 8 += 2

e. 8 -+ 2

Your answer is correct.

The correct answer is: 8 ** 2

Question 29 Correct Mark 1.00 out of 1.00

What will the output of this python program be?

def test_function( length, width, height):


    print ("the area of the box is ",length*width*height)
    return length*width*height

l = 12.5
w=5
h=2
test_function(l, w, h)

Select one:

a. The area of the box is 125

b. The area of the box is 125.0

c. The area of the box is 120

d. 125.0

The correct answer is: The area of the box is 125.0


/
Question 30 Incorrect Mark 0.00 out of 1.00

What is the output of the following Python program?

try:
    n = open('answer.txt')
    n.write('Yes')
except:
    print('No')
print('Maybe')

Select one:

a. Yes

b. No

c. Maybe

d. Yes
Maybe

e. No
Maybe

Your answer is incorrect.

The correct answer is: No


Maybe

◄ Learning Guide Unit 9

Jump to...

Final Exam ►

/
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  Final Exam (Days 1 - 4)  Review Quiz

Started on Friday, 30 October 2020, 9:22 AM


State Finished
Completed on Friday, 30 October 2020, 9:27 AM
Time taken 4 mins 52 secs
Marks 9.57/30.00
Grade 31.89 out of 100.00

Question 1 Incorrect Mark 0.00 out of 1.00

Which one of the following Python expressions generates a syntax error?

Select one:

a. 8 ^ 2

b. 8 ** 2

c. 8 +- 2

d. 8 += 2

e. 8 -+ 2

Your answer is incorrect.

The correct answer is: 8 += 2

/
Question 2 Correct Mark 1.00 out of 1.00

What output will the following code produce?

n = 10
while n != 1:
    print (n,end=' ')
    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 3 Incorrect Mark 0.00 out of 1.00

 If you use a Python dictionary in a for statement, it traverses the _____ of the
dictionary.

Select one:

a. values and keys

b. indices

c. keys and values

d. values

e. keys

Your answer is incorrect.

The correct answer is: keys


/
Question 4 Correct Mark 1.00 out of 1.00

Which one of the following Python expressions has the value 64?

Select one:

a. 8 ^ 2

b. 8 ** 2

c. 8 +- 2

d. 8 += 2

e. 8 -+ 2

Your answer is correct.

The correct answer is: 8 ** 2

Question 5 Incorrect Mark 0.00 out of 1.00

What does function subroutine do?

def subroutine( n ):
  while n > 0:
      print (n,)
      n -= 1

Select one:

a. Counts from 10 down to 0 and displays each number

b. Counts from n down to 1 and displays each number

c. Calculates the sum of n numbers greater than 0

d. Calculates the mean of n

The correct answer is: Counts from n down to 1 and displays each number

/
Question 6 Incorrect Mark 0.00 out of 1.00

A development approach that that is intended to avoid a lot of debugging by only


adding and testing small amounts of code at a time is called.

Select one:

a. structured development

b. incremental development

c. unit testing

d. Systems development life cycle

The correct answer is: incremental development

/
Question 7 Correct Mark 1.00 out of 1.00

What output will the following code produce?

mylist = [ [2,4,1], [1,2,3], [2,3,5] ]


a=0
b=0
total = 0
while a <= 2:
    while b < 2:
        total += mylist[a][b]
        b += 1
    a += 1
    b = 0 
print (total)

Select one:

a. 14

b. 23

c. 0

d. 13

The correct answer is: 14

/
Question 8 Correct Mark 1.00 out of 1.00

Consider the following Python program.

n = open('words.txt')
for line in n:
    word = line.strip()
    print(word)

What does the program loop over?

Select one:

a. Lines in a le

b. Lines in a list

c. Words in a dictionary

d. Words in a list

e. Words in a string

Your answer is correct.

The correct answer is: Lines in a le

/
Question 9 Partially correct Mark 0.07 out of 1.00

Match concepts with their de nition.

natural language
An error in a program.

The process of nding and removing any of the three kinds of natural language

programming errors.

Any one of the languages that people have designed for speci c
natural language
purposes, such as representing mathematical ideas or computer
programs; all programming languages are this kind of languages.

A programming language like Python that is designed to be easy natural language

for humans to read and write.

natural language
A program that reads another program and executes it.

A programming language that is designed to be easy for a


natural language
computer to execute; also called machine language or assembly
language.

natural language
Any one of the languages that people speak that evolved naturally.

natural language
To examine a program and analyse the syntactic structure.

A property of a program that can run on more than one kind of natural language

computer.

An instruction that causes the Python interpreter to display a value natural language

on the screen.

The process of formulating a problem, nding a solution, and natural language

expressing the solution.

a sequence of instructions that speci es to a computer actions and natural language

computations to be performed.

low-level language
A program stored in a le (usually one that will be interpreted).

/
One of the basic elements of the syntactic structure of a program, problem solving

analogous to a word in a natural language.

program
The structure of a program.

The correct answer is: An error in a program. → bug, The process of nding and removing
any of the three kinds of programming errors. → debugging, Any one of the languages that
people have designed for speci c purposes, such as representing mathematical ideas or
computer programs; all programming languages are this kind of languages. → formal
language, A programming language like Python that is designed to be easy for humans to
read and write. → high-level language, A program that reads another program and executes
it. → interpreter, A programming language that is designed to be easy for a computer to
execute; also called machine language or assembly language. → low-level language, Any one
of the languages that people speak that evolved naturally. → natural language, To examine a
program and analyse the syntactic structure. → parse, A property of a program that can run
on more than one kind of computer. → portability, An instruction that causes the Python
interpreter to display a value on the screen. → print statement, The process of formulating a
problem, nding a solution, and expressing the solution. → problem solving, a sequence of
instructions that speci es to a computer actions and computations to be performed. →
program, A program stored in a le (usually one that will be interpreted). → script, One of the
basic elements of the syntactic structure of a program, analogous to a word in a natural
language. → token, The structure of a program. → syntax

/
Question 10 Incorrect Mark 0.00 out of 1.00

What is Python’s response to the command: type(0.123)

Select one:

a. <class ' oat'>

b. <class 'bool'>

c. SyntaxError: invalid syntax

d. <class 'int'>

e. <class 'str'>

Your answer is incorrect.

The correct answer is: <class ' oat'>

Question 11 Correct Mark 1.00 out of 1.00

What output will the following Python 3 program produce?

x=5
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 12 Incorrect Mark 0.00 out of 1.00

The elements of a list are immutable.

Select one:

True

False

The correct answer is 'False'.

Question 13 Incorrect Mark 0.00 out of 1.00

What is the output of the following Python statements?

def recurse(a):
    if (a == 0):
        print(a)
    else:
        recurse(a) 

recurse(1)

Select one:

a. 0

b. 1

c. no output

d. RuntimeError: maximum recursion depth exceeded

Your answer is incorrect.

The correct answer is: RuntimeError: maximum recursion depth exceeded

/
Question 14 Correct Mark 1.00 out of 1.00

Consider the following Python program.

n = open('words.txt')
for line in n:
    word = line.strip()
    print(word)

What is n?

Select one:

a. A le object

b. A list of characters

c. A list of words

d. A string that may have a newline

e. A string with no newline

Your answer is correct.

The correct answer is: A le object

/
Question 15 Incorrect Mark 0.00 out of 1.00

What is the output of the Python method call below?

"bib". nd('b', 1, 2)

Select one:

a. 0

b. 2

c. -1

d. syntax error

e. 3

Your answer is incorrect.

The correct answer is: -1

Question 16 Correct Mark 1.00 out of 1.00

What is the value of the following Python expression?

not(True and False)

Select one:

True

False

The correct answer is 'True'.

/
Question 17 Correct Mark 1.00 out of 1.00

The Python line below causes “5 dollars” to be printed.

print('%d %s' % (5, 'dollars'))

Select one:

True

False

The correct answer is 'True'.

Question 18 Incorrect Mark 0.00 out of 1.00

For the Python program below, will there be any output, and will the program
terminate?

while True:

while 1 > 0:

break

print("Got it!")

break

Select one:

a. Yes and no

b. No and no

c. Yes and yes

d. No and yes

e. Run-time error

Your answer is incorrect.

The correct answer is: Yes and yes

/
Question 19 Incorrect Mark 0.00 out of 1.00

Handling an exception with a try statement is called throwing an exception.

Select one:

True

False

The correct answer is 'False'.

Question 20 Incorrect Mark 0.00 out of 1.00

Which of the following types are allowed for Python dictionary keys?

Select one:

a. dictionary

b. list

c. list of dictionaries

d. tuple

e. All of the above

Your answer is incorrect.

The correct answer is: tuple

/
Question 21 Incorrect Mark 0.00 out of 1.00

Given a Python dictionary d and a value v, it is e cient to nd the corresponding


key: d[k] = v.

Select one:

True

False

The correct answer is 'False'.

/
Question 22 Partially correct Mark 0.50 out of 1.00

Match concepts with their de nition!

Any one of the languages that people have designed for speci c
formal language
purposes, such as representing mathematical ideas or computer
programs; all programming languages are this kind of languages.

semantics
Any one of the languages that people speak that evolved naturally.

An error that does not occur until the program has started to execute formal language

but that prevents the program from continuing.

An error in a program that makes it do something other than what syntax

the programmer intended.

semantics
The meaning of a program.

syntax
The structure of a program.

An error in a program that makes it impossible to parse — and syntax

therefore impossible to interpret.

One of the basic elements of the syntactic structure of a program, token

analogous to a word in a natural language.

The correct answer is: Any one of the languages that people have designed for speci c
purposes, such as representing mathematical ideas or computer programs; all programming
languages are this kind of languages. → formal language, Any one of the languages that
people speak that evolved naturally. → natural language, An error that does not occur until
the program has started to execute but that prevents the program from continuing. →
runtime error, An error in a program that makes it do something other than what the
programmer intended. → semantic error, The meaning of a program. → semantics, The
structure of a program. → syntax, An error in a program that makes it impossible to parse —
and therefore impossible to interpret. → syntax error, One of the basic elements of the
syntactic structure of a program, analogous to a word in a natural language. → token

/
Question 23 Incorrect Mark 0.00 out of 1.00

A variable that has a data type of "str" cannot be part of a compound data type

Select one:

True

False

The correct answer is 'False'.

Question 24 Incorrect Mark 0.00 out of 1.00

What output will the following python commands produce:

x=1
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

/
Question 25 Incorrect Mark 0.00 out of 1.00

What is Python’s response to the command: type(123)

Select one:

a. <class ' oat'>

b. <class 'bool'>

c. SyntaxError: invalid syntax

d. <class 'int'>

e. <class 'str'>

Your answer is incorrect.

The correct answer is: <class 'int'>

Question 26 Incorrect Mark 0.00 out of 1.00

What is the output of the Python code below?

my_list = [3, 2, 1]
print(my_list.sort())

Select one:

a. 0

b. {1, 2, 3}

c. None

d. syntax error

e. [1, 2, 3]

Your answer is incorrect.

The correct answer is: None

/
Question 27 Incorrect Mark 0.00 out of 1.00

What output will the following code produce?

print ("%s %d %f" % (5, 5, 5))

Select one:

a. 5 5 5.000000

b. 5 5 5

c. 5 5.000000

d. 0 5 5.0

The correct answer is: 5 5 5.000000

Question 28 Incorrect Mark 0.00 out of 1.00

What is the output of the following Python program?

mylist = [ [2,4,1], [1,2,3], [2,3,5] ]


total = 0
for sublist in mylist:
    total += sum(sublist)
print(total) 

Select one:

a. 14

b. 23

c. 0

d. 13

Your answer is incorrect.

The correct answer is: 23

/
Question 29 Correct Mark 1.00 out of 1.00

What output will the following Python script produce?

def function2(param):
    print (param, param)

def function1(part1, part2):


    cat = part1 + part2
    function2(cat)

chant1 = "See Me "


chant2 = "See You "
function1(chant1, chant2)

Select one:

a. See You See Me

b. See Me See You See Me See You

c. See Me See Me See You See You

d. None it would generate an error

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

/
Question 30 Incorrect Mark 0.00 out of 1.00

What is the output of the following Python program?

try:
    n = open('answer.txt')
    n.write('Yes')
except:
    print('No')
print('Maybe')

Select one:

a. Yes

b. No

c. Maybe

d. Yes
Maybe

e. No
Maybe

Your answer is incorrect.

The correct answer is: No


Maybe

◄ Learning Guide Unit 9

Jump to...

Final Exam ►

/
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  Final Exam (Days 1 - 4)  Review Quiz

Started on Tuesday, 27 October 2020, 11:50 AM


State Finished
Completed on Tuesday, 27 October 2020, 12:14 PM
Time taken 23 mins 38 secs
Marks 18.75/30.00
Grade 62.50 out of 100.00

Question 1 Incorrect Mark 0.00 out of 1.00

Consider the following Python program.

n = open('words.txt')
for line in n:
    word = line.strip()
    print(word)

What is line?

Select one:

a. A le object

b. A list of characters

c. A list of words

d. A string that may have a newline

e. A string with no newline

Your answer is incorrect.

The correct answer is: A string that may have a newline

/
Question 2 Correct Mark 1.00 out of 1.00

What output will the following Python 3 program produce?

x=5
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 3 Correct Mark 1.00 out of 1.00

What output will the following Python script produce?

def function2(param):
    print (param, param)

def function1(part1, part2):


    cat = part1 + part2
    function2(cat)

chant1 = "See Me "


chant2 = "See You "
function1(chant1, chant2)

Select one:

a. See You See Me

b. See Me See You See Me See You

c. See Me See Me See You See You

d. None it would generate an error

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

/
Question 4 Correct Mark 1.00 out of 1.00

: The following code:

for fruit in ["banana", "apple", "quince"]:


    print (fruit)
  
will produce the following output:

banana
apple
quince

Select one:

True

False

The correct answer is 'True'.

/
Question 5 Correct Mark 1.00 out of 1.00

Consider the following Python program.

n = open('words.txt')
for line in n:
    word = line.strip()
    print(word)

What does the program loop over?

Select one:

a. Lines in a le

b. Lines in a list

c. Words in a dictionary

d. Words in a list

e. Words in a string

Your answer is correct.

The correct answer is: Lines in a le

/
Question 6 Incorrect Mark 0.00 out of 1.00

Assume that d is a Python dictionary. What does the following Python code produce?

for k in d:
    if d[k] == v:
        return k

Select one:

a. a histogram

b. an inverted dictionary

c. a list of tuples

d. a lookup

e. a reverse lookup

Your answer is incorrect.

The correct answer is: a reverse lookup

Question 7 Correct Mark 1.00 out of 1.00

What is the output of the following Python program?

index = "Ability is a poor man's wealth". nd("W")


print(index)

Select one:

a. 24

b. 0

c. 23

d. -1

Your answer is correct.

The correct answer is: -1

/
Question 8 Correct Mark 1.00 out of 1.00

What output will the following code produce?

print ("%s %d %f" % (5, 5, 5))

Select one:

a. 5 5 5.000000

b. 5 5 5

c. 5 5.000000

d. 0 5 5.0

The correct answer is: 5 5 5.000000

Question 9 Correct Mark 1.00 out of 1.00

When a Python function is called, inside the function, the arguments are assigned to
variables called parameters.

Select one:

True

False

The correct answer is 'True'.

/
Question 10 Correct Mark 1.00 out of 1.00

What output will the following code produce?

def area(l, w):


    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

/
Question 11 Correct Mark 1.00 out of 1.00

What is the output of the Python code below?

my_list = [3, 2, 1]
print(my_list)

Select one:

a. 0

b. {3, 2, 1}

c. None

d. syntax error

e. [3, 2, 1]

Your answer is correct.

The correct answer is: [3, 2, 1]

Question 12 Correct Mark 1.00 out of 1.00

What is the output of the Python method call below?

"bib". nd('b', 1, 2)

Select one:

a. 0

b. 2

c. -1

d. syntax error

e. 3

Your answer is correct.

The correct answer is: -1

/
Question 13 Correct Mark 1.00 out of 1.00

What output will the following code produce?

n = 10
while n != 1:
    print (n,end=' ')
    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 14 Incorrect Mark 0.00 out of 1.00

Consider the following Python program.

n = open('words.txt')
for line in n:
    word = line.strip()
    print(word)

What is n?

Select one:

a. A le object

b. A list of characters

c. A list of words

d. A string that may have a newline

e. A string with no newline

Your answer is incorrect.

The correct answer is: A le object

Question 15 Incorrect Mark 0.00 out of 1.00

The elements of a list are immutable.

Select one:

True

False

The correct answer is 'False'.

/
Question 16 Correct Mark 1.00 out of 1.00

The Python line below causes “5 dollars” to be printed.

print('%d %s' % (5, 'dollars'))

Select one:

True

False

The correct answer is 'True'.

/
Question 17 Partially correct Mark 0.75 out of 1.00

Match concepts with their de nition!

Any one of the languages that people have designed for speci c
formal language
purposes, such as representing mathematical ideas or computer
programs; all programming languages are this kind of languages.

natural language
Any one of the languages that people speak that evolved naturally.

An error that does not occur until the program has started to execute runtime error

but that prevents the program from continuing.

An error in a program that makes it do something other than what semantic error

the programmer intended.

syntax
The meaning of a program.

syntax
The structure of a program.

An error in a program that makes it impossible to parse — and syntax error

therefore impossible to interpret.

One of the basic elements of the syntactic structure of a program, semantics

analogous to a word in a natural language.

The correct answer is: Any one of the languages that people have designed for speci c
purposes, such as representing mathematical ideas or computer programs; all programming
languages are this kind of languages. → formal language, Any one of the languages that
people speak that evolved naturally. → natural language, An error that does not occur until
the program has started to execute but that prevents the program from continuing. →
runtime error, An error in a program that makes it do something other than what the
programmer intended. → semantic error, The meaning of a program. → semantics, The
structure of a program. → syntax, An error in a program that makes it impossible to parse —
and therefore impossible to interpret. → syntax error, One of the basic elements of the
syntactic structure of a program, analogous to a word in a natural language. → token

/
Question 18 Correct Mark 1.00 out of 1.00

What is Python’s response to the command: type(123)

Select one:

a. <class ' oat'>

b. <class 'bool'>

c. SyntaxError: invalid syntax

d. <class 'int'>

e. <class 'str'>

Your answer is correct.

The correct answer is: <class 'int'>

Question 19 Incorrect Mark 0.00 out of 1.00

Assume that d is a Python dictionary. What does the following Python code produce?

d.items()

Select one:

a. a histogram

b. an inverted dictionary

c. a list of tuples

d. a lookup

e. a reverse lookup

Your answer is incorrect.

The correct answer is: a list of tuples

/
Question 20 Incorrect Mark 0.00 out of 1.00

What is the value of the following Python expression?

not(True and False)

Select one:

True

False

The correct answer is 'True'.

Question 21 Correct Mark 1.00 out of 1.00

What is the output of the following Python statements?

def recurse(a):
    if (a == 0):
        print(a)
    else:
        recurse(a) 

recurse(1)

Select one:

a. 0

b. 1

c. no output

d. RuntimeError: maximum recursion depth exceeded

Your answer is correct.

The correct answer is: RuntimeError: maximum recursion depth exceeded

/
Question 22 Correct Mark 1.00 out of 1.00

What is the output of the following Python program?

mylist = [ [2,4,1], [1,2,3], [2,3,5] ]


total = 0
for sublist in mylist:
    total += sum(sublist)
print(total) 

Select one:

a. 14

b. 23

c. 0

d. 13

Your answer is correct.

The correct answer is: 23

Question 23 Correct Mark 1.00 out of 1.00

Which of the following types are allowed for Python dictionary values?

Select one:

a. dictionary

b. list

c. list of dictionaries

d. tuple

e. all of the above

Your answer is correct.

The correct answer is: all of the above

/
Question 24 Correct Mark 1.00 out of 1.00

Boolean expressions control _________________

Select one:

a. recursion

b. conditional execution

c. alternative execution

d. all of the above

The correct answer is: all of the above

Question 25 Incorrect Mark 0.00 out of 1.00

If you assign the result a void function to a variable in Python, you get:

Select one:

a. an empty string

b. the value -1

c. the value 0

d. the special value None

e. an exception

Your answer is incorrect.

The correct answer is: the special value None

/
Question 26 Incorrect Mark 0.00 out of 1.00

Handling an exception with a try statement is called throwing an exception.

Select one:

True

False

The correct answer is 'False'.

Question 27 Incorrect Mark 0.00 out of 1.00

Which of the following types are allowed for Python dictionary keys?

Select one:

a. dictionary

b. list

c. list of dictionaries

d. tuple

e. All of the above

Your answer is incorrect.

The correct answer is: tuple

/
Question 28 Correct Mark 1.00 out of 1.00

A development approach that that is intended to avoid a lot of debugging by only


adding and testing small amounts of code at a time is called.

Select one:

a. structured development

b. incremental development

c. unit testing

d. Systems development life cycle

The correct answer is: incremental development

Question 29 Incorrect Mark 0.00 out of 1.00

 If you use a Python dictionary in a for statement, it traverses the _____ of the
dictionary.

Select one:

a. values and keys

b. indices

c. keys and values

d. values

e. keys

Your answer is incorrect.

The correct answer is: keys

/
Question 30 Incorrect Mark 0.00 out of 1.00

For the Python program below, will there be any output, and will the program
terminate?

while True:

while 1 > 0:

break

print("Got it!")

break

Select one:

a. Yes and no

b. No and no

c. Yes and yes

d. No and yes

e. Run-time error

Your answer is incorrect.

The correct answer is: Yes and yes

◄ Learning Guide Unit 9

Jump to...

Final Exam ►

You might also like