You are on page 1of 130

Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  3 September - 9 September  Self-Quiz Unit 1

Started on Saturday, 5 September 2020, 9:00 AM


State Finished
Completed on Saturday, 5 September 2020, 9:10 AM
Time taken 10 mins 2 secs
Grade 8.00 out of 10.00 (80%)

Question 1 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 'str'>


Question 2 Correct Mark 1.00 out of 1.00

Consider the following text from a Python interpreter.

>>> print(2 + 2)

What is the text "print(2 + 2)" called?

Select one:

a. a function

b. an operator

c. a prompt

d. a statement

e. a value

Your answer is correct.

The correct answer is: a statement

Question 3 Correct Mark 1.00 out of 1.00

What does the Python interpreter output for the following input?

>>> 1,234.567,890

Select one:

a. 1234

b. 1234.6

c. 1234.56789

d. (1, 234.567, 890)

e. SyntaxError: invalid token

Your answer is correct.

The correct answer is: (1, 234.567, 890)


Question 4 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 5 Correct Mark 1.00 out of 1.00

Consider the following text from a Python interpreter.

>>> print(2 + 2)

What is the text "4" called?

Select one:

a. a function

b. an operator

c. a prompt

d. a statement

e. a value

Your answer is correct.

The correct answer is: a value


Question 6 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 7 Incorrect Mark 0.00 out of 1.00

Which one of the following words best describes formal languages?

Select one:

a. ambiguity

b. literalness

c. poetry

d. prose

e. redundancy

Your answer is incorrect.

The correct answer is: literalness


Question 8 Correct Mark 1.00 out of 1.00

Which of the following is not a valid Python numeric literal:

Select one:

a. 123

b. 0123

c. 0.00

d. 12.3

e. 0.75

Your answer is correct.

The correct answer is: 0123

Question 9 Correct Mark 1.00 out of 1.00

Which one of the following Python expressions computes the total number of seconds in 21
minutes and 21 seconds?

Select one:

a. 21 + 21

b. 21 + 60

c. "21 minutes" + "21 seconds"

d. 21 * 60 + 21

e. seconds = 21 + "21 minutes"

Your answer is correct.

The correct answer is: 21 * 60 + 21


Question 10 Correct Mark 1.00 out of 1.00

Programming languages are ______ languages that have been designed to express computations.

Select one:

a. informal

b. mathematical

c. formal

d. natural

e. logical

Your answer is correct.

The correct answer is: formal

← Learning Journal Unit 1

Jump to...

Learning Guide Unit 2 →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  3 September - 9 September  Self-Quiz Unit 1

Started on Saturday, 5 September 2020, 8:44 AM


State Finished
Completed on Saturday, 5 September 2020, 8:59 AM
Time taken 15 mins 33 secs
Grade 10.00 out of 10.00 (100%)

Question 1 Correct Mark 1.00 out of 1.00

Which one of the following Python expressions computes the number of miles in 5 km, where one
mile is 1.61 km? 

Select one:

a. 5 * 1.61

b. 5 / 1.61

c. 1.61 / 5

d. 1.61 + 5

e. miles = "5 km"

Your answer is correct.

The correct answer is: 5 / 1.61


Question 2 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 3 Correct Mark 1.00 out of 1.00

string is a Python type that represents sequences of numeric values.

Select one:

True

False

The correct answer is 'False'.


Question 4 Correct Mark 1.00 out of 1.00

Consider the following text from a Python interpreter.

>>> print(2 + 2)

What is the text ">>>" called?

Select one:

a. a function

b. an operator

c. a prompt

d. a statement

e. a value

Your answer is correct.

The correct answer is: a prompt

Question 5 Correct Mark 1.00 out of 1.00

Consider the following text from a Python interpreter.

>>> print(2 + 2)

What is the text "+" called?

Select one:

a. a function

b. an operator

c. a prompt

d. a statement

e. a value

Your answer is correct.

The correct answer is: an operator


Question 6 Correct Mark 1.00 out of 1.00

Consider the following text from a Python interpreter.

>>> print(2 + 2)

What is the text "print" called?

Select one:

a. a function

b. an operator

c. a prompt

d. a statement

e. a value

Your answer is correct.

The correct answer is: a function

Question 7 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 8 Correct Mark 1.00 out of 1.00

Portability means the program is written in small chunks of code.

Select one:

True

False

The correct answer is 'False'.

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

The correct answer is: 8 ^ 2

Question 10 Correct Mark 1.00 out of 1.00

True or False: 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'.

← Learning Journal Unit 1

Jump to...
Learning Guide Unit 2 →
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  10 September - 16 September  Self-Quiz Unit 2

Started on Wednesday, 16 September 2020, 7:09 AM


State Finished
Completed on Wednesday, 16 September 2020, 7:18 AM
Time taken 8 mins 37 secs
Grade 4.13 out of 10.00 (41%)

Question 1 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 2 Partially correct Mark 0.13 out of 1.00

Match concepts with their de nition!

expression
A statement that creates a new variable and gives it a value.

Information in a program that is meant for other programmers (or anyone concatenate

reading the source code) and has no e ect on the execution of the program.

The ability to combine simple expressions and statements into compound


composition
statements and expressions in order to represent complex computations
concisely.

concatenate
To join two operands end-to-end.

concatenate
What the Python interpreter does to an expression to nd its value.

A combination of variables, operators, and values that represents a single variable

result value.

operand
A Python data type that stores oating-point numbers.

operand
A Python data type that holds positive and negative whole numbers.

concatenate
A reserved word that is used by the interpreter to parse programs.

evaluate
One of the values on which an operator operates.

A special symbol that represents a simple computation like addition, str

multiplication, or string concatenation.

evaluate
A unit of code that the Python interpreter can execute.

comment
A Python data type that holds a string of characters.

A number or letter that can be stored in a variable or evaluated in an composition

expression.

operand
A name that refers to a value.
The correct answer is: A statement that creates a new variable and gives it a value. → assignment
statement, Information in a program that is meant for other programmers (or anyone reading the source
code) and has no e ect on the execution of the program. → comment, The ability to combine simple
expressions and statements into compound statements and expressions in order to represent complex
computations concisely. → composition, To join two operands end-to-end. → concatenate, What the Python
interpreter does to an expression to nd its value. → evaluate, A combination of variables, operators, and
values that represents a single result value. → expression, A Python data type that stores oating-point
numbers. → oat, A Python data type that holds positive and negative whole numbers. → int, A reserved
word that is used by the interpreter to parse programs. → keyword, One of the values on which an operator
operates. → operand, A special symbol that represents a simple computation like addition, multiplication,
or string concatenation. → operator, A unit of code that the Python interpreter can execute. → statement, A
Python data type that holds a string of characters. → str, A number or letter that can be stored in a variable
or evaluated in an expression. → value, A name that refers to a value. → variable

Question 3 Incorrect Mark 0.00 out of 1.00

The * operator also works on strings for which it performs repetition.

Select one:

True

False

The correct answer is 'True'.

Question 4 Correct Mark 1.00 out of 1.00

An expression is a combination of values, variables, and operators. If you type an expression on


the command line, the interpreter evaluates it and displays the result.

Select one:

True

False

The correct answer is 'True'.


Question 5 Incorrect Mark 0.00 out of 1.00

In Python, the ‘+’ operator can be used with numbers and with strings. What is a property that
number addition has, but string concatenation does not?

Select one:

a. numeric addition is allowed on right-hand side of assignment statement

b. more than one numeric addition per expression is allowed

c. expression value does not depend on the order of numeric addition operands

d. numeric addition is fast to execute

e. numeric addition needs 2 operands

Your answer is incorrect.

The correct answer is: expression value does not depend on the order of numeric addition operands

Question 6 Correct Mark 1.00 out of 1.00

A script usually contains a sequence of statements. If there is more than one statement, the
results appear one at a time as the statements execute.

Select one:

True

False

The correct answer is 'True'.


Question 7 Incorrect Mark 0.00 out of 1.00

1. What is the output of the code below assuming that global variable x has value 2 and global
y has value 3?

def f1():

    return "ab"

 def f2():

    return f1() * x

 def f3():

    return f2() + f1() * y

 print(f3())

Select one:

a. ababababababababab

b. abababababab

c. abababab

d. ababab

e. ababababab

Your answer is incorrect.

The correct answer is: ababababab

Question 8 Incorrect Mark 0.00 out of 1.00

What output will the following Python statement produce?

>>> print ((1,000,000))

Select one:

a. 1,000

b. 1,000,000

c. (1, 0, 0)

d. Error invalid type

The correct answer is: (1, 0, 0)


Question 9 Correct Mark 1.00 out of 1.00

The acronym PEMDAS is a way to remember the order of operations in Python.

Select one:

True

False

The correct answer is 'True'.

Question 10 Incorrect Mark 0.00 out of 1.00

In a script, an expression all by itself is a legal statement, but it does not do anything.

Select one:

True

False

The correct answer is 'True'.

← Learning Journal Unit 2

Jump to...

Learning Guide Unit 3 →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  10 September - 16 September  Self-Quiz Unit 2

Started on Wednesday, 16 September 2020, 7:18 AM


State Finished
Completed on Wednesday, 16 September 2020, 7:21 AM
Time taken 2 mins 56 secs
Grade 8.00 out of 10.00 (80%)

Question 1 Correct Mark 1.00 out of 1.00

What output will the following Python statements produce?

>>> n = 17
>>> print (n)

Select one:

a. (n)

b. 17.0

c. n

d. 17

The correct answer is: 17

Question 2 Correct Mark 1.00 out of 1.00

 In Python, the expression “a ** (b ** c)” is the same as “(a ** b)

Select one:

True

False

The correct answer is 'False'.


Question 3 Incorrect Mark 0.00 out of 1.00

What is the output of the Python code below when run in script mode?

y=3

x=5

x+y

“x + y”

Select one:

a. 8

b. x + y

c. no output

d. run-time error

e. compile error

Your answer is incorrect.

The correct answer is: no output

Question 4 Correct Mark 1.00 out of 1.00

Python functions may or may not take arguments and may or may not return a result.

Select one:

True

False

The correct answer is 'True'.


Question 5 Correct Mark 1.00 out of 1.00

Using Python keywords for variable names will result in a ________________

Select one:

a. runtime error

b. compile error

c. syntax error

d. semantic error

The correct answer is: syntax error

Question 6 Correct Mark 1.00 out of 1.00

What output will the following Python statements produce?

>>> print (2*3-1)

Select one:

a. 6

b. 5

c. 4

d. 3

The correct answer is: 5


Question 7 Incorrect Mark 0.00 out of 1.00

What output will the following Python statements produce?

>>>percentage = ( 60.0 * 100.0 ) / 55.0


>>>print (percentage)

Select one:

a. percentage

b. 109

c. 109.0909090909091

d. 109.0

The correct answer is: 109.0909090909091

Question 8 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 9 Correct Mark 1.00 out of 1.00

Which of the following is an invalid Python assignment statement?

Select one:

a. a = b = 123

b. ‘3’ = 3

c. x = int(“123”)

d. y = None

e. z = “hi” * 10

Your answer is correct.

The correct answer is: ‘3’ = 3 


Question 10 Correct Mark 1.00 out of 1.00

Programmers generally choose names for their variables that are meaningful and document what
the variable is used for.

Select one:

True

False

The correct answer is 'True'.

← Learning Journal Unit 2

Jump to...

Learning Guide Unit 3 →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  10 September - 16 September  Self-Quiz Unit 2

Started on Wednesday, 16 September 2020, 7:22 AM


State Finished
Completed on Wednesday, 16 September 2020, 7:26 AM
Time taken 4 mins 26 secs
Grade 7.00 out of 10.00 (70%)

Question 1 Correct Mark 1.00 out of 1.00

What output will the following Python statements produce?

>>> print (2*(3 - 1))

Select one:

a. 6

b. 5

c. 4

d. 3

The correct answer is: 4

Question 2 Correct Mark 1.00 out of 1.00

A program is a sequence of instructions that speci es how to perform a computation.

Select one:

True

False

The correct answer is 'True'.


Question 3 Incorrect Mark 0.00 out of 1.00

When de ning a Python function that has no parameters, the parentheses that follow the
function’s name are optional.

Select one:

True

False

The correct answer is 'False'.

Question 4 Correct Mark 1.00 out of 1.00

As programs get bigger and more complicated, they get more di cult to read. This is one reason
why programmers should use comments in their code.

Select one:

True

False

The correct answer is 'True'.

Question 5 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 6 Correct Mark 1.00 out of 1.00

What do we call the value provided to a function when the function is called (which is assigned to
the corresponding parameter in the function)?

Select one:

a. argument

b. return value

c. method

d. the special value None

e. global variable

Your answer is correct.

The correct answer is: argument

Question 7 Correct Mark 1.00 out of 1.00

A property of a program that can run on more than one kind of computer is called portability.

Select one:

True

False

The correct answer is 'True'.

Question 8 Correct Mark 1.00 out of 1.00

What output will the following Python statements produce?

>>> print ((1+1)**(5-2))

Select one:

a. 16

b. 8

c. 4

d. 2

The correct answer is: 8


Question 9 Incorrect Mark 0.00 out of 1.00

An error that is detected while the program is running is referred to as:

Select one:

a. a syntax error

b. an exception

c. a compilation error

d. a semantic error

e. a late error

Your answer is incorrect.

The correct answer is: an exception

Question 10 Correct Mark 1.00 out of 1.00

An expression is a combination of values, variables, and operators. If you type an expression on


the command line, the interpreter evaluates it and displays the result.

Select one:

True

False

The correct answer is 'True'.

← Learning Journal Unit 2

Jump to...

Learning Guide Unit 3 →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  17 September - 23 September  Self-Quiz Unit 3

Started on Sunday, 20 September 2020, 3:31 PM


State Finished
Completed on Sunday, 20 September 2020, 3:31 PM
Time taken 19 secs
Grade 0.00 out of 10.00 (0%)

Question 1 Not answered Marked 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 2 Not answered Marked 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(0)

Select one:

a. 0

b. 1

c. no output

d. RuntimeError: maximum recursion depth exceeded

Your answer is incorrect.

The correct answer is: 0

Question 3 Not answered Marked out of 1.00

One way to generalize a function is to replace a variable with a value.

Select one:

True

False

The correct answer is 'False'.


Question 4 Not answered Marked out of 1.00

What output will the following python command produce:

>>> percentage =  oat ( 60 * 100) / 55


>>> print (percentage)

Select one:

a. percentage

b. 109

c. 109.0909090909091

d. 109.0

The correct answer is: 109.0909090909091

Question 5 Not answered Marked out of 1.00

What is the output of the following Python statements?

pi = int(3.14159)
print (pi)

Select one:

a. 3

b. 3.0

c. 3.14159

d. 0

Your answer is incorrect.

The correct answer is: 3


Question 6 Not answered Marked out of 1.00

True/False: The % or modulus operator returns the remainder present when two integers do not
divide evenly into one another

Select one:

True

False

The correct answer is 'True'.

Question 7 Not answered Marked out of 1.00

 Occasionally, it is useful to have a body of an if statement that does nothing. In that case, you
can use the following statement:

Select one:

a. # do nothing

b. 0 = 0

c. Null

d. pass

e. Void

Your answer is incorrect.

The correct answer is: pass


Question 8 Not answered Marked 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 9 Not answered Marked out of 1.00

What is the output of the following Python statements?

x=5

if x % 2 == 1:

    print (x)

else:

    print (x, x%2)

Select one:

a. 5

b. (5, 1)

c. 2

d. (5, 0)

Your answer is incorrect.

The correct answer is: 5


Question 10 Not answered Marked out of 1.00

Expressions evaluate to either true or false.  What will the output of the following code be when
the  expression “Ni!” is evaluated?

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!"

← Learning Journal Unit 3

Jump to...

Graded Quiz Unit 3 →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  17 September - 23 September  Self-Quiz Unit 3

Started on Sunday, 20 September 2020, 3:31 PM


State Finished
Completed on Sunday, 20 September 2020, 3:32 PM
Time taken 29 secs
Grade 0.00 out of 10.00 (0%)

Question 1 Not answered Marked 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 2 Not answered Marked out of 1.00

Match the following terms and de nitions

The order in which statements are executed during a program run. Choose...

The rst part of a compound statement, begins with a keyword and ends with a
Choose...
colon ( : )
A statement that executes a function. It consists of the name of the function
Choose...
followed by a list of arguments enclosed in parentheses.

A variable de ned inside a function that can only be used inside its function. Choose...

A graphical representation of functions, their variables, and the values to which


Choose...
they refer.

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

Question 3 Not answered Marked 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 4 Not answered Marked out of 1.00

What is the output of the following Python statements?

percentage = ( 60 * 100) // 55
print (percentage)

Select one:

a. percentage

b. 109

c. 109.0909090909091

d. 109.0

Your answer is incorrect.

The correct answer is: 109

Question 5 Not answered Marked 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 6 Not answered Marked out of 1.00

How many di erent values can a Boolean expression have?

Select one:

a. 3

b. 2

c. in nite number

d. 1

e. not de ned

Your answer is incorrect.

The correct answer is: 2

Question 7 Not answered Marked out of 1.00

Functions allow the programmer to encapsulate and generalize sections of code.

Select one:

True

False

The correct answer is 'True'.

Question 8 Not answered Marked 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 9 Not answered Marked 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 10 Not answered Marked out of 1.00

True/False: The % or modulus operator returns the remainder present when two integers do not
divide evenly into one another

Select one:

True

False

The correct answer is 'True'.

← Learning Journal Unit 3

Jump to...

Graded Quiz Unit 3 →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  17 September - 23 September  Self-Quiz Unit 3

Started on Sunday, 20 September 2020, 3:32 PM


State Finished
Completed on Sunday, 20 September 2020, 3:33 PM
Time taken 38 secs
Grade 0.00 out of 10.00 (0%)

Question 1 Not answered Marked 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 2 Not answered Marked 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 Not answered Marked 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(0)

Select one:

a. 0

b. 1

c. no output

d. RuntimeError: maximum recursion depth exceeded

Your answer is incorrect.

The correct answer is: 0


Question 4 Not answered Marked 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 5 Not answered Marked out of 1.00

Match the following terms and de nitions

The order in which statements are executed during a program run. Choose...

The rst part of a compound statement, begins with a keyword and ends with a
Choose...
colon ( : )
A statement that executes a function. It consists of the name of the function
Choose...
followed by a list of arguments enclosed in parentheses.

A variable de ned inside a function that can only be used inside its function. Choose...

A graphical representation of functions, their variables, and the values to which


Choose...
they refer.

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
Question 6 Not answered Marked 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 7 Not answered Marked out of 1.00

What output will the following python command produce:

>>> percentage =  oat ( 60 * 100) / 55


>>> print (percentage)

Select one:

a. percentage

b. 109

c. 109.0909090909091

d. 109.0

The correct answer is: 109.0909090909091


Question 8 Not answered Marked out of 1.00

 Occasionally, it is useful to have a body of an if statement that does nothing. In that case, you
can use the following statement:

Select one:

a. # do nothing

b. 0 = 0

c. Null

d. pass

e. Void

Your answer is incorrect.

The correct answer is: pass

Question 9 Not answered Marked out of 1.00

Expressions evaluate to either true or false.  What will the output of the following code be when
the  expression “Ni!” is evaluated?

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!"
Question 10 Not answered Marked out of 1.00

What is the output of the following Python statements?

pi = int(3.14159)
print (pi)

Select one:

a. 3

b. 3.0

c. 3.14159

d. 0

Your answer is incorrect.

The correct answer is: 3

← Learning Journal Unit 3

Jump to...

Graded Quiz Unit 3 →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  17 September - 23 September  Graded Quiz Unit 3

Started on Sunday, 20 September 2020, 3:36 PM


State Finished
Completed on Sunday, 20 September 2020, 4:06 PM
Time taken 30 mins 3 secs
Marks 17.25/20.00
Grade 86.25 out of 100.00

Question 1 Correct Mark 1.00 out of 1.00

Python functions may or may not take arguments and may or may not return a result.

Select one:

True

False

The correct answer is 'True'.

Question 2 Correct Mark 1.00 out of 1.00

If you assign the result of calling 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 3 Correct Mark 1.00 out of 1.00

What do we call the value provided to a function when the function is called (which is assigned to
the corresponding parameter in the function)?

Select one:

a. argument

b. return value

c. method

d. the special value None

e. global variable

Your answer is correct.

The correct answer is: argument

Question 4 Correct Mark 1.00 out of 1.00

Consider the following text from a Python interpreter.

>>> print(2 + 2)
4

What is the text "print" called?

Select one:

a. a function

b. an operator

c. a prompt

d. a statement

e. a value

Your answer is correct.

The correct answer is: a function


Question 5 Correct Mark 1.00 out of 1.00

What output will the following Python statement produce?

>>> print (2*3-1)

Select one:

a. 6

b. 5

c. 4

d. 3

The correct answer is: 5

Question 6 Correct Mark 1.00 out of 1.00

What is the output of the following Python statements?

def recurse(a):
    if (a == 1):
        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: 1


Question 7 Correct Mark 1.00 out of 1.00

What is the output of the following Python statements?

percentage = ( 60 * 100) // 55
print (percentage)

Select one:

a. percentage

b. 109

c. 109.0909090909091

d. 109.0

Your answer is correct.

The correct answer is: 109

Question 8 Correct Mark 1.00 out of 1.00

What output will the following Python statements produce?

>>> n = 17
>>> print (n)

Select one:

a. 0

b. 17.0

c. n

d. 17

The correct answer is: 17


Question 9 Correct Mark 1.00 out of 1.00

Using keywords for variable names will result in a ________________

Select one:

a. runtime error

b. compile error

c. syntax error

d. semantic error

The correct answer is: syntax error

Question 10 Not answered Marked out of 1.00

A program is a sequence of instructions that speci es how to perform a computation.

Select one:

True

False

The correct answer is 'True'.

Question 11 Correct Mark 1.00 out of 1.00

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

Select one:

a. 2 ^ 2

b. 2 ** 2

c. 2 +- 2

d. 2 += 2

e. 2 -+ 2

Your answer is correct.

The correct answer is: 2 += 2


Question 12 Correct Mark 1.00 out of 1.00

What output will the following Python statement produce?

>>> print ((1+1)**(5-2))

Select one:

a. 16

b. 8

c. 4

d. 2

The correct answer is: 8

Question 13 Correct Mark 1.00 out of 1.00

What output will the following Python statements produce?

>>> percentage = ( 60.0 * 100.0) / 55.0


>>> print (percentage)

Select one:

a. percentage

b. 109

c. 109.0909090909091

d. 109.0

The correct answer is: 109.0909090909091


Question 14 Correct Mark 1.00 out of 1.00

Consider the following text from a Python interpreter.

>>> print(2 + 2)
4

What is the text "+" called?

Select one:

a. a function

b. an operator

c. a prompt

d. a statement

e. a value

Your answer is correct.

The correct answer is: an operator

Question 15 Correct Mark 1.00 out of 1.00

Which of the following is an invalid Python assignment statement?

Select one:

a. a = b = 123

b. ‘3’ = 3

c. x = int(“123”)

d. y = None

e. z = “hi” * 10

Your answer is correct.

The correct answer is: ‘3’ = 3


Question 16 Correct Mark 1.00 out of 1.00

The % or modulus operator returns the remainder from dividing two numbers.

Select one:

True

False

The correct answer is 'True'.

Question 17 Incorrect Mark 0.00 out of 1.00

In Python, the ‘+’ operator can be used with numbers and with strings. What is a property that
number addition has, but string concatenation does not?

Select one:

a. Numeric addition is allowed on right-hand side of assignment statement.

b. More than one numeric addition per expression is allowed.

c. The expression value does not depend on the order of numeric addition operands.

d. Numeric addition is fast to execute.

e. Numeric addition needs two operands.

Your answer is incorrect.

The correct answer is: The expression value does not depend on the order of numeric addition operands.
Question 18 Correct Mark 1.00 out of 1.00

What is the output of the following Python 3 statements?

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

Your answer is correct.

The correct answer is: 2 is greater than 1


Question 19 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 purposes, such as
formal language
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 but that syntax

prevents the program from continuing.

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

programmer intended.

formal language
The meaning of a program.

semantics
The structure of a program.

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

impossible to interpret.

One of the basic elements of the syntactic structure of a program, analogous to a syntax

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 20 Correct Mark 1.00 out of 1.00

Match concepts with their de nition!

concatenate
To join two operands end-to-end.

evaluate
What the Python interpreter does to an expression to nd its value.

expression
A combination of variables, operators, and values that represents a single result value.

keyword
A reserved word that is used by the interpreter to parse programs.

A special symbol that represents a simple computation like addition, multiplication, or operator

string concatenation.

statement
A unit of code that the Python interpreter can execute.

variable
A name that refers to a value.

The correct answer is: To join two operands end-to-end. → concatenate, What the Python interpreter does
to an expression to nd its value. → evaluate, A combination of variables, operators, and values that
represents a single result value. → expression, A reserved word that is used by the interpreter to parse
programs. → keyword, A special symbol that represents a simple computation like addition, multiplication,
or string concatenation. → operator, A unit of code that the Python interpreter can execute. → statement, A
name that refers to a value. → variable

← Self-Quiz Unit 3

Jump to...

Unit 2 Programming Assignment Sample Solution →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  1 October - 7 October  Self-Quiz Unit 5

Started on Wednesday, 7 October 2020, 3:54 PM


State Finished
Completed on Wednesday, 7 October 2020, 3:57 PM
Time taken 3 mins 20 secs
Grade 7.00 out of 10.00 (70%)

Question 1 Correct Mark 1.00 out of 1.00

Python allows while loops inside while loops and if statements within the body of if statements.

Select one:

True

False

The correct answer is 'True'.

Question 2 Correct Mark 1.00 out of 1.00

A Python loop where the terminating condition is never achieved is called _______.

Select one:

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 3 Incorrect Mark 0.00 out of 1.00

The statements inside of a Python loop are known as the ____ of the loop.

Select one:

a. body

b. expression

c. counter

d. block

The correct answer is: body

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

What does Python function subroutine do?

def subroutine( n ):
    while n > 0:
        print (n,)
    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

Repeated execution of a set of programming statements is called repetitive execution.

Select one:

True

False

The correct answer is 'False'.


Question 7 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 8 Correct Mark 1.00 out of 1.00

What output will the following statements produce using Python in interactive mode?

>>> n = 2
>>> n = n + 5
>>> n

Select one:

a. 7

b. 5

c. 2

d. an error message will occur

The correct answer is: 7


Question 9 Incorrect Mark 0.00 out of 1.00

A Python string is a sequence of characters. You can access the string characters with the _______.

Select one:

a. () operator

b. % operator

c. dot operator

d. // operator

e. [] operator

Your answer is incorrect.

The correct answer is: [] operator

Question 10 Correct Mark 1.00 out of 1.00

The following Python code illustrates what programming concept?

bruce = 5
print (bruce,)
bruce = 7
print (bruce)

Select one:

a. Reassignment

b. Iteration

c. Logical operators

d. Conditionals

The correct answer is: Reassignment

← Learning Journal Unit 5

Jump to...

Unit 4 Programming Sample Solution →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  1 October - 7 October  Self-Quiz Unit 5

Started on Wednesday, 7 October 2020, 3:57 PM


State Finished
Completed on Wednesday, 7 October 2020, 4:00 PM
Time taken 2 mins 23 secs
Grade 4.00 out of 10.00 (40%)

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

An algorithm is a general process for solving a category of problems.

Select one:

True

False

The correct answer is 'True'. 


Question 3 Incorrect Mark 0.00 out of 1.00

The following Python code succeeds in modifying the rst character of the string to “Y”.

fred = "Hello"
fred[0] = "Y"

Select one:

True

False

The correct answer is 'False'.

Question 4 Incorrect Mark 0.00 out of 1.00

What output will the following Python program produce?

n = 10
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 5 Correct Mark 1.00 out of 1.00

What is the value of the following Python expression?

"Xanadu" > "Yellowstone"

Select one:

True

False

The correct answer is 'False'.

Question 6 Incorrect Mark 0.00 out of 1.00

Repeated execution of a set of programming statements is called repetitive execution.

Select one:

True

False

The correct answer is 'False'.

Question 7 Incorrect Mark 0.00 out of 1.00

A Python string is a sequence of characters. You can access the string characters with the _______.

Select one:

a. () operator

b. % operator

c. dot operator

d. // operator

e. [] operator

Your answer is incorrect.

The correct answer is: [] operator


Question 8 Correct Mark 1.00 out of 1.00

What does Python function subroutine do?

def subroutine( n ):
    while n > 0:
        print (n,)
    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 9 Not answered Marked out of 1.00

Python allows while loops inside while loops and if statements within the body of if statements.

Select one:

True

False

The correct answer is 'True'.


Question 10 Correct Mark 1.00 out of 1.00

The following Python code illustrates what programming concept?

bruce = 5
print (bruce,)
bruce = 7
print (bruce)

Select one:

a. Reassignment

b. Iteration

c. Logical operators

d. Conditionals

The correct answer is: Reassignment

← Learning Journal Unit 5

Jump to...

Unit 4 Programming Sample Solution →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  1 October - 7 October  Self-Quiz Unit 5

Started on Wednesday, 7 October 2020, 4:00 PM


State Finished
Completed on Wednesday, 7 October 2020, 4:02 PM
Time taken 2 mins 30 secs
Grade 6.00 out of 10.00 (60%)

Question 1 Correct Mark 1.00 out of 1.00

An algorithm is a general process for solving a category of problems.

Select one:

True

False

The correct answer is 'True'.

Question 2 Correct Mark 1.00 out of 1.00

A Python loop where the terminating condition is never achieved is called _______.

Select one:

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 3 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 4 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 5 Correct Mark 1.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 6 Correct Mark 1.00 out of 1.00

What output will the following Python program produce?

n = 10
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 7 Incorrect Mark 0.00 out of 1.00

The following Python code succeeds in modifying the rst character of the string to “Y”.

fred = "Hello"
fred[0] = "Y"

Select one:

True

False

The correct answer is 'False'.

Question 8 Correct Mark 1.00 out of 1.00

What is the value of the following Python expression?

"Xanadu" > "Yellowstone"

Select one:

True

False

The correct answer is 'False'.

Question 9 Correct Mark 1.00 out of 1.00

What output will the following statements produce using Python in interactive mode?

>>> n = 2
>>> n = n + 5
>>> n

Select one:

a. 7

b. 5

c. 2

d. an error message will occur

The correct answer is: 7


Question 10 Incorrect Mark 0.00 out of 1.00

The statements inside of a Python loop are known as the ____ of the loop.

Select one:

a. body

b. expression

c. counter

d. block

The correct answer is: body

← Learning Journal Unit 5

Jump to...

Unit 4 Programming Sample Solution →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  8 October - 14 October  Self-Quiz Unit 6

Started on Sunday, 11 October 2020, 5:15 PM


State Finished
Completed on Sunday, 11 October 2020, 5:22 PM
Time taken 7 mins 3 secs
Grade 7.00 out of 10.00 (70%)

Question 1 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 2 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

The correct answer is: 24


Question 3 Correct Mark 1.00 out of 1.00

What is the output of the following Python program? 

fruit = "banana"
letter = fruit[1]
print (letter)

Select one:

a. b

b. a

c. n

d. banana

The correct answer is: a

Question 4 Incorrect Mark 0.00 out of 1.00

This Python code:

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


    print (fruit)

will produce this output:

banana apple quince

Select one:

True

False

The correct answer is 'False'.


Question 5 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] ]


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

Select one:

a. 14

b. 23

c. 0

d. 13

The correct answer is: 14

Question 6 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 7 Correct Mark 1.00 out of 1.00

What is the output of the following Python 3 program?

mylist = ["now", "four", "is", "score", "the", "and seven", "time", "years", "for"]
a=0
while a < 8:
    print(mylist[a],)
  a=a+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

The correct answer is: now is the time

Question 8 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 9 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 10 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.sort())

Select one:

a. 0

b. {1, 2, 3}

c. None

d. syntax error

e. [1, 2, 3]

Your answer is correct.

The correct answer is: None

← Learning Journal Unit 6

Jump to...

Graded Quiz Unit 6 →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  8 October - 14 October  Self-Quiz Unit 6

Started on Sunday, 11 October 2020, 5:22 PM


State Finished
Completed on Sunday, 11 October 2020, 5:30 PM
Time taken 7 mins 46 secs
Grade 6.00 out of 10.00 (60%)

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 Incorrect Mark 0.00 out of 1.00

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

Select one:

True

False

The correct answer is 'False'.


Question 3 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 4 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 5 Correct Mark 1.00 out of 1.00

Traversal can only be accomplished with the "while" loop.

Select one:

True

False

The correct answer is 'False'.

Question 6 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)

Select one:

a. 0

b. {3, 2, 1}

c. None

d. syntax error

e. [3, 2, 1]

Your answer is incorrect.

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


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

The correct answer is: four score and seven years

Question 8 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 9 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 10 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

The correct answer is: 24

← Learning Journal Unit 6

Jump to...

Graded Quiz Unit 6 →


Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  8 October - 14 October  Self-Quiz Unit 6

Started on Sunday, 11 October 2020, 5:31 PM


State Finished
Completed on Sunday, 11 October 2020, 5:31 PM
Time taken 20 secs
Grade 0.00 out of 10.00 (0%)

Question 1 Incorrect Mark 0.00 out of 1.00

What is the output of the following Python 3 program?

mylist = ["now", "four", "is", "score", "the", "and seven", "time", "years", "for"]
a=0
while a < 8:
    print(mylist[a],)
  a=a+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

The correct answer is: now is the time


Question 2 Not answered Marked 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 3 Not answered Marked out of 1.00

Traversal can only be accomplished with the "while" loop.

Select one:

True

False

The correct answer is 'False'.


Question 4 Not answered Marked 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 5 Not answered Marked 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 6 Not answered Marked out of 1.00

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

Select one:

True

False

The correct answer is 'True'.

Question 7 Not answered Marked 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 incorrect.

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


Question 8 Not answered Marked 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 9 Not answered Marked out of 1.00

This Python code:

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


    print (fruit)

will produce this output:

banana apple quince

Select one:

True

False

The correct answer is 'False'.


Question 10 Not answered Marked out of 1.00

What is the output of the following Python program? 

fruit = "banana"
letter = fruit[1]
print (letter)

Select one:

a. b

b. a

c. n

d. banana

The correct answer is: a

← Learning Journal Unit 6

Jump to...

Graded Quiz Unit 6 →


1
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  15 October - 21 October  Self-Quiz Unit 7

Started on Wednesday, 21 October 2020, 5:45 AM


State Finished
Completed on Wednesday, 21 October 2020, 5:47 AM
Time taken 1 min 40 secs
Grade 6.00 out of 10.00 (60%)

Question 1 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 2 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 3 Incorrect Mark 0.00 out of 1.00

What is the value of the following Python expression?

(0, 1, 5, 2) > (0, 1.0, 4, 3.1)

Select one:

a. 0

b. 1

c. False

d. True

e. syntax error

Your answer is incorrect.

The correct answer is: True

/
Question 4 Incorrect Mark 0.00 out of 1.00

What will the contents of mylist be after the following Python 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 5 Correct Mark 1.00 out of 1.00

In the following segment of Python code, what do we call the portion of the
statement that follows the dot('.capitalize')?

str.capitalize('maryland')

Select one:

a. Module

b. Method

c. Attribute

d. Function name

The correct answer is: Method

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

What is the output of the Python code below?

my_tup = (3, 2, 1, 2)
print(tuple(sorted(my_tup)))

Select one:

a. (1, 2, 3)

b. {1, 2, 2, 3}

c. (1, 2, 2, 3)

d. syntax error

e. [1, 2, 2, 3]

Your answer is correct.

The correct answer is: (1, 2, 2, 3)

/
Question 8 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 9 Incorrect Mark 0.00 out of 1.00

Python tuples are immutable.

Select one:

True

False

The correct answer is 'True'.

/
Question 10 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'.

◄ Learning Journal Unit 7

Jump to...

Learning Guide Unit 8 ►

/
1
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  15 October - 21 October  Self-Quiz Unit 7

Started on Wednesday, 21 October 2020, 5:42 AM


State Finished
Completed on Wednesday, 21 October 2020, 5:43 AM
Time taken 1 min 59 secs
Grade 4.00 out of 10.00 (40%)

Question 1 Incorrect Mark 0.00 out of 1.00

What is the output of the Python code below?

my_tup = (3, 2, 1, 2)
print(tuple(sorted(my_tup)))

Select one:

a. (1, 2, 3)

b. {1, 2, 2, 3}

c. (1, 2, 2, 3)

d. syntax error

e. [1, 2, 2, 3]

Your answer is incorrect.

The correct answer is: (1, 2, 2, 3)

/
Question 2 Correct Mark 1.00 out of 1.00

Traversal can only be accomplished with the "while" loop.

Select one:

True

False

The correct answer is 'False'.

Question 3 Incorrect Mark 0.00 out of 1.00

What is the output of the Python code below?

print(dict().get("no", "help!"))

Select one:

a. True

b. no

c. no help!

d. help!

e. False

Your answer is incorrect.

The correct answer is: help!

/
Question 4 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 5 Not answered Marked 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 6 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 7 Incorrect Mark 0.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 incorrect.

The correct answer is: All of the above

/
Question 8 Incorrect Mark 0.00 out of 1.00

What will the contents of mylist be after the following Python 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 9 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 10 Correct Mark 1.00 out of 1.00

Python tuples are immutable.

Select one:

True

False

The correct answer is 'True'.

◄ Learning Journal Unit 7

Jump to...

Learning Guide Unit 8 ►

/
1
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  15 October - 21 October  Self-Quiz Unit 7

Started on Wednesday, 21 October 2020, 5:44 AM


State Finished
Completed on Wednesday, 21 October 2020, 5:45 AM
Time taken 1 min 21 secs
Grade 4.00 out of 10.00 (40%)

Question 1 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 2 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 3 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 4 Correct Mark 1.00 out of 1.00

Python functions can take a variable number of arguments.

Select one:

True

False

The correct answer is 'True'.

/
Question 5 Incorrect Mark 0.00 out of 1.00

What is the value of the following Python expression?

(0, 1, 5, 2) > (0, 1.0, 4, 3.1)

Select one:

a. 0

b. 1

c. False

d. True

e. syntax error

Your answer is incorrect.

The correct answer is: True

Question 6 Correct Mark 1.00 out of 1.00

Python dictionaries are mutable.

Select one:

True

False

The correct answer is 'True'.

/
Question 7 Incorrect Mark 0.00 out of 1.00

In the following segment of Python code, what do we call the portion of the
statement that follows the dot('.capitalize')?

str.capitalize('maryland')

Select one:

a. Module

b. Method

c. Attribute

d. Function name

The correct answer is: Method

Question 8 Correct Mark 1.00 out of 1.00

Traversal can only be accomplished with the "while" loop.

Select one:

True

False

The correct answer is 'False'.

/
Question 9 Not answered Marked out of 1.00

What is the output of the Python code below?

print(dict().get("no", "help!"))

Select one:

a. True

b. no

c. no help!

d. help!

e. False

Your answer is incorrect.

The correct answer is: help!

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

◄ Learning Journal Unit 7

Jump to...
/
Learning Guide Unit 8 ►

/
1
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  22 October - 28 October  Self-Quiz Unit 8

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


State Finished
Completed on Tuesday, 27 October 2020, 11:34 AM
Time taken 8 mins 40 secs
Grade 5.00 out of 10.00 (50%)

Question 1 Incorrect Mark 0.00 out of 1.00

Assume the following Python code has already executed.

import os
cwd = os.getcwd()

Which answer is most likely output from the following Python statement?

os.path.is le(cwd)

Select one:

a. ['Music', 'Pictures', 'Desktop', 'Library', 'Documents', 'Downloads']

b. False

c. True

d. /Users/me

e. /Users/me/Documents/ le.txt

Your answer is incorrect.

The correct answer is: False

/
Question 2 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 3 Correct Mark 1.00 out of 1.00

What is the output from the following interactive Python statement?

>>> '%d' % (0.1)

Select one:

a. '0'

b. '0.1'

c. TypeError: oat argument required, not str

d. TypeError: not all arguments converted during string formatting

e. TypeError: not enough arguments for format string

Your answer is correct.

The correct answer is: '0'

/
Question 4 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 5 Correct Mark 1.00 out of 1.00

Assume the following Python code has already executed.

import os
cwd = os.getcwd()

Which answer is most likely output from the following Python statement?

os.path.abspath(cwd)

Select one:

a. ['Music', 'Pictures', 'Desktop', 'Library', 'Documents', 'Downloads']

b. False

c. True

d. /Users/me

e. /Users/me/Documents/ le.txt

Your answer is correct.

The correct answer is: /Users/me

/
Question 6 Correct Mark 1.00 out of 1.00

What is the output of the Python code below?

print('%d + %d + %d = %d' % (1, 2, 3, 1+2+3))

Select one:

a. 6

b. (1 + 2 + 3 = 6)

c. None

d. 1 + 2 + 3 = 6

e. “1 + 2 + 3 = 6”

Your answer is correct.

The correct answer is: 1 + 2 + 3 = 6

Question 7 Incorrect Mark 0.00 out of 1.00

Which of the following Python statements runs without error?

Select one:

a. open('three.txt').write(3)

b. open('three.txt','w').write(3)

c. open('three.txt','w').write(str(3))

d. All of the above

e. None of the above

Your answer is incorrect.

The correct answer is: open('three.txt','w').write(str(3))

/
Question 8 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 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 incorrect.

The correct answer is: Lines in a le

/
Question 9 Correct Mark 1.00 out of 1.00

What is the output from the following interactive Python statement?

>>> '%g' % (0,1)

Select one:

a. '0'

b. '0.1'

c. TypeError: oat argument required, not str

d. TypeError: not all arguments converted during string formatting

e. TypeError: not enough arguments for format string

Your answer is correct.

The correct answer is: TypeError: not all arguments converted during string formatting

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

◄ Learning Journal Unit 8

Jump to...

CS 1101 Course Evaluation ►

/
1
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  22 October - 28 October  Self-Quiz Unit 8

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


State Finished
Completed on Tuesday, 27 October 2020, 11:43 AM
Time taken 8 mins 37 secs
Grade 5.00 out of 10.00 (50%)

Question 1 Correct Mark 1.00 out of 1.00

Assume the following Python code has already executed.

import os
cwd = os.getcwd()

Which answer is most likely output from the following Python statement?

os.path.isdir(cwd)

Select one:

a. ['Music', 'Pictures', 'Desktop', 'Library', 'Documents', 'Downloads']

b. False

c. True

d. /Users/me

e. /Users/me/Documents/ le.txt

Your answer is correct.

The correct answer is: True

/
Question 2 Correct Mark 1.00 out of 1.00

What is the output from the following interactive Python statement?

>>> '%g %d' % (0.1)

Select one:

a. '0'

b. '0.1'

c. TypeError: oat argument required, not str

d. TypeError: not all arguments converted during string formatting

e. TypeError: not enough arguments for format string

Your answer is correct.

The correct answer is: TypeError: not enough arguments for format string

/
Question 3 Incorrect Mark 0.00 out of 1.00

Assume the following Python code has already executed.

import os
cwd = os.getcwd()

Which answer is most likely output from the following Python statement?

os.path.join(cwd, 'Documents/ le.txt')

Select one:

a. ['Music', 'Pictures', 'Desktop', 'Library', 'Documents', 'Downloads']

b. False

c. True

d. /Users/me

e. /Users/me/Documents/ le.txt

Your answer is incorrect.

The correct answer is: /Users/me/Documents/ le.txt

/
Question 4 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 5 Incorrect Mark 0.00 out of 1.00

Exceptions allow the programmer to _________________.

Select one:

a. override all runtime errors

b. write code to handle runtime errors

c. ignore syntax errors

d. load data from a le

The correct answer is: write code to handle runtime errors

/
Question 6 Incorrect Mark 0.00 out of 1.00

Assume the following Python code has already executed.

import os
cwd = os.getcwd()

Which answer is most likely output from the following Python statement?

os.listdir(cwd)

Select one:

a. ['Music', 'Pictures', 'Desktop', 'Library', 'Documents', 'Downloads']

b. False

c. True

d. /Users/me

e. /Users/me/Documents/ le.txt

Your answer is incorrect.

The correct answer is: ['Music', 'Pictures', 'Desktop', 'Library', 'Documents', 'Downloads']

/
Question 7 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 8 Incorrect Mark 0.00 out of 1.00

What is the output from the following interactive Python statement?

>>> '%g' % (0.1)

Select one:

a. '0'

b. '0.1'

c. TypeError: oat argument required, not str

d. TypeError: not all arguments converted during string formatting

e. TypeError: not enough arguments for format string

Your answer is incorrect.

The correct answer is: '0.1'

Question 9 Correct Mark 1.00 out of 1.00

What is the output from the following interactive Python statement?

>>> '%g' % '0.1'

Select one:

a. '0'

b. '0.1'

c. TypeError: oat argument required, not str

d. TypeError: not all arguments converted during string formatting

e. TypeError: not enough arguments for format string

Your answer is correct.

The correct answer is: TypeError: oat argument required, not str

/
Question 10 Correct Mark 1.00 out of 1.00

Assume the following Python code has already executed.

import os
cwd = os.getcwd()

Which answer is most likely output from the following Python statement?

os.path.exists(cwd)

Select one:

a. ['Music', 'Pictures', 'Desktop', 'Library', 'Documents', 'Downloads']

b. False

c. True

d. /Users/me

e. /Users/me/Documents/ le.txt

Your answer is correct.

The correct answer is: True

◄ Learning Journal Unit 8

Jump to...

CS 1101 Course Evaluation ►

/
1
Raymond Enokela

Home  My courses  CS 1101 - AY2021-T1  22 October - 28 October  Self-Quiz Unit 8

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


State Finished
Completed on Tuesday, 27 October 2020, 11:48 AM
Time taken 3 mins 39 secs
Grade 5.00 out of 10.00 (50%)

Question 1 Correct Mark 1.00 out of 1.00

What is the output from the following interactive Python statement?

>>> '%g' % (0.1)

Select one:

a. '0'

b. '0.1'

c. TypeError: oat argument required, not str

d. TypeError: not all arguments converted during string formatting

e. TypeError: not enough arguments for format string

Your answer is correct.

The correct answer is: '0.1'

/
Question 2 Correct Mark 1.00 out of 1.00

What is the output of the Python code below?

print('%d + %d + %d = %d' % (1, 2, 3, 1+2+3))

Select one:

a. 6

b. (1 + 2 + 3 = 6)

c. None

d. 1 + 2 + 3 = 6

e. “1 + 2 + 3 = 6”

Your answer is correct.

The correct answer is: 1 + 2 + 3 = 6

/
Question 3 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 4 Correct Mark 1.00 out of 1.00

Assume the following Python code has already executed.

import os
cwd = os.getcwd()

Which answer is most likely output from the following Python statement?

os.path.join(cwd, 'Documents/ le.txt')

Select one:

a. ['Music', 'Pictures', 'Desktop', 'Library', 'Documents', 'Downloads']

b. False

c. True

d. /Users/me

e. /Users/me/Documents/ le.txt

Your answer is correct.

The correct answer is: /Users/me/Documents/ le.txt

Question 5 Incorrect Mark 0.00 out of 1.00

Which of the following Python statements runs without error?

Select one:

a. open('three.txt').write(3)

b. open('three.txt','w').write(3)

c. open('three.txt','w').write(str(3))

d. All of the above

e. None of the above

Your answer is incorrect.

The correct answer is: open('three.txt','w').write(str(3))

/
Question 6 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 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 incorrect.

The correct answer is: Lines in a le

/
Question 7 Correct Mark 1.00 out of 1.00

What is the output from the following interactive Python statement?

>>> '%g' % (0,1)

Select one:

a. '0'

b. '0.1'

c. TypeError: oat argument required, not str

d. TypeError: not all arguments converted during string formatting

e. TypeError: not enough arguments for format string

Your answer is correct.

The correct answer is: TypeError: not all arguments converted during string formatting

/
Question 8 Incorrect Mark 0.00 out of 1.00

Assume the following Python code has already executed.

import os
cwd = os.getcwd()

Which answer is most likely output from the following Python statement?

os.path.abspath(cwd)

Select one:

a. ['Music', 'Pictures', 'Desktop', 'Library', 'Documents', 'Downloads']

b. False

c. True

d. /Users/me

e. /Users/me/Documents/ le.txt

Your answer is incorrect.

The correct answer is: /Users/me

/
Question 9 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 10 Correct Mark 1.00 out of 1.00

What is the output from the following interactive Python statement?

>>> '%g %d' % (0.1)

Select one:

a. '0'

b. '0.1'

c. TypeError: oat argument required, not str

d. TypeError: not all arguments converted during string formatting

e. TypeError: not enough arguments for format string

Your answer is correct.

The correct answer is: TypeError: not enough arguments for format string

◄ Learning Journal Unit 8

Jump to...

CS 1101 Course Evaluation ►

You might also like