100% found this document useful (1 vote)
135 views19 pages

Python Programming Quiz Results

Nabeel Fahim completed a review quiz for their CS 1101 course on August 15, 2020. The quiz contained 20 multiple choice questions covering topics like Python functions, data types, conditionals, and debugging. Nabeel answered 17 questions correctly, earning a score of 27 out of a possible 30 points, equivalent to a grade of 90% overall.

Uploaded by

NabeelSa'adFahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
135 views19 pages

Python Programming Quiz Results

Nabeel Fahim completed a review quiz for their CS 1101 course on August 15, 2020. The quiz contained 20 multiple choice questions covering topics like Python functions, data types, conditionals, and debugging. Nabeel answered 17 questions correctly, earning a score of 27 out of a possible 30 points, equivalent to a grade of 90% overall.

Uploaded by

NabeelSa'adFahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Nabeel Fahim

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

Started on Saturday, 15 August 2020, 8:47 PM


State Finished
Completed on Saturday, 15 August 2020, 9:07 PM
Time taken 19 mins 44 secs
Marks 27.00/30.00
Grade 90.00 out of 100.00

Question 1 Correct Mark 1.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 correct.

The correct answer is: the special value None

/
Question 2 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 3 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 4 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 5 Correct Mark 1.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 correct.

The correct answer is: a list of tuples

/
Question 6 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 7 Correct Mark 1.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 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

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 correct.

The correct answer is: tuple

/
Question 10 Correct Mark 1.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 correct.

The correct answer is: No


Maybe

/
Question 11 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 12 Correct Mark 1.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 13 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 14 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 15 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 16 Correct Mark 1.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 correct.

The correct answer is: 8 += 2

Question 17 Correct Mark 1.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 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 Correct Mark 1.00 out of 1.00

Match concepts with their de nition.

bug
An error in a program.

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

programming errors.

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.

A programming language like Python that is designed to be easy high-level language

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


low-level language
computer to execute; also called machine language or assembly
language.

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

naturally.

parse
To examine a program and analyse the syntactic structure.

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

computer.

An instruction that causes the Python interpreter to display a print statement

value on the screen.

The process of formulating a problem, nding a solution, and problem solving

expressing the solution.

a sequence of instructions that speci es to a computer actions program

and computations to be performed.

script
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.

/
syntax
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 20 Incorrect Mark 0.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 incorrect.

The correct answer is: -1

/
Question 21 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 22 Correct Mark 1.00 out of 1.00

String objects are modi ed with string slices.

Select one:

True

False

The correct answer is 'False'.

Question 23 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 24 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 25 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 26 Correct Mark 1.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 correct.

The correct answer is: a reverse lookup

/
Question 27 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 28 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 29 Correct Mark 1.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 correct.

The correct answer is: Yes and yes

/
Question 30 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

◀ Learning Guide Unit 9


Jump to...

Final Exam ▶

You might also like