CS 1101 PROGRAMMING FUNDAMENTALS
FINAL EXAM
Question 1
Correct
Mark 1.00 out of 1.00
Flag question
Question text
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
Feedback
Your answer is correct.
The correct answer is: 23
Question 2
Correct
Mark 1.00 out of 1.00
Flag question
Question text
Match concepts with their definition!
,Any one of the languages that people have designed for specific Answer 1
purposes, such as representing mathematical ideas or computer formal language
programs; all programming languages are this kind of languages.
Answer 2
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 Answer 3
but that prevents the program from continuing. runtime error
An error in a program that makes it do something other than what the Answer 4
semantic error
programmer intended.
Answer 5
The meaning of a program. semantics
Answer 6
The structure of a program. syntax
An error in a program that makes it impossible to parse — and Answer 7
therefore impossible to interpret. syntax error
One of the basic elements of the syntactic structure of a program, Answer 8
token
analogous to a word in a natural language.
Feedback
The correct answer is: Any one of the languages that people have designed
for specific 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
Flag question
Question text
What is Python’s response to the command: type(0.123)
Select one:
a.
<class 'float'>
, b.
<class 'bool'>
c.
SyntaxError: invalid syntax
d.
<class 'int'>
e.
<class 'str'>
Feedback
Your answer is correct.
The correct answer is: <class 'float'>
Question 4
Correct
Mark 1.00 out of 1.00
Flag question
Question text
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.