

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Master Python fundamentals with this comprehensive final exam. Test your knowledge on mutable/immutable objects, loops, lambda functions, and decorators. Great for engineering and computer science students.
Typology: Exams
1 / 25
This page cannot be seen from the preview
Don't miss anything!


















Name: _________________________ Score: ______ / ______
Final Exam
Part 1
Which of the following objects is immutable? A. Dictionary B. List C. Set D. Tuple Answer Point Value: 1.0 points Answer Key: D
Which of the following objects is mutable? A. Float B. String C. Frozen Set D. Boolean E. None of the Above Answer Point Value: 1.0 points Answer Key: E In Python, everything is an object. True False Answer Point Value: 1.0 points
Answer Key: True
When creating the variable, b = 10, b contains the value 10. True False
Answer Point Value: 1.0 points Answer Key: False
An object whose internal data can be changed is called a ____ object. Answer Point Value: 1.0 points Answer Key: mutable
Fill in the command such that the type of variable x is printed. print(____) Answer Point Value: 1.0 points Answer Key: type(x)
Which of the following is a valid python comment? A. // This is a comment. B. $ This is a comment. C. @ This is a comment. D. # This is a comment.
Answer Point Value: 1.0 points Answer Key: D
The loop: for i in range(17, 42): print(i) will print out ____ values starting with ____ and ending with ____
Answer Point Value: 3.0 points Answer Key: 25, 17, 42
Casting a string variable holding a string-encoded float value as an integer will result in an integer variable type. True False
Answer Point Value: 1.0 points Answer Key: False
What will be printed? Attachments
A. Goodbye B. Hello IDK... C. IDK... D. Hello Goodbye E. Hello F. Hello Goodbye IDK...
Answer Point Value: 1.0 points Answer Key: E
The output of the following code will be: Attachments
A. This is my course! B. This might be my course? C. This is not my course! D. An error is produced.
Answer Point Value: 1.0 points Answer Key: D
Given: x = [x**2 for x in range(3, 10, 2)] the variable x is a ____ containing ____ elements, the first being ____ and the last being ____. Answer Point Value: 4.0 points Answer Key: list, 4, 9, 81
Attachments
The output of this code block will be ____ Answer Point Value: 1.0 points Answer Key: 21
Attachments
Answer Point Value: 4.0 points Answer Key: 10, What function is this?, This is function 2, Now I know...
Given the variable: x = "myString" The command that creates an iterator from variable x is:
Answer Point Value: 1.0 points Answer Key: iter(x)
Given the attached code, the character m will be the result of the first print statement and the character y will be the result of the second print statement. Attachments
True False
Answer Point Value: 1.0 points Answer Key: False
Attachments
Given the attached code, function1 is classified as a ____. Answer Point Value: 1.0 points Answer Key: generator
Attachments
An equivalent lambda function for the attached function using the same variables and notation. is:
Answer Point Value: 1.0 points Answer Key: lambda a,b : a if a > b else b
Attachments
The result of the attached code is:
Answer Point Value: 1.0 points Answer Key: [45, 67, 23]
In regular expressions, the ^ metacharacter denotes: A. A set of characters B. Ends with C. Starts with D. Signals a special sequence
Answer Point Value: 1.0 points Answer Key: C
The command "ECE9013: Intro to Programming for Engineers".upper() converts every character in the string to its uppercase value. True False
Answer Point Value: 1.0 points Answer Key: True
The result of the following command is: "ECE9013: Intro to Programming for Engineers".capitalize()
Answer Point Value: 1.0 points Answer Key: Ece9013: intro to programming for engineers
The attached code block prints a reversed string x. Attachments
True False
Answer Point Value: 1.0 points Answer Key: True
Attachments
The result of thee attached codeblock is ____ Answer Point Value: 1.0 points Answer Key: E
Which of the attached lines of code produce to an error? Attachments
A. Line 1 B. Line 2 C. Line 3 D. None of the lines of code produce an error.
Answer Point Value: 1.0 points Answer Key: B
When running the attached code, how many times will the statement "Still running" be printed? Attachments
A. The statement will be printed one time. B. The statement will not be printed. C. The code results in an infinite loop; the statement will be printed an infinite number of times. D. There is an error in the code; the statement will not be printed.
Answer Point Value: 1.0 points Answer Key: B
Attachments
The output of the following code block is ____ list(range(-3,9,3)) Answer Point Value: 1.0 points Answer Key: [-3, 0, 3, 6]
What is the output of the attached code?
Attachments
Answer Point Value: 1.0 points Answer Key: B
Which of the following returns an empty set? A. set(range(3,3)) B. set(range(1, -3, -5)) C. set(-2, 4, 3)) D. All other options return empty sets.
Answer Point Value: 1.0 points Answer Key: A
Attachments
The output of the attached code is ____. NOTE: If you believe the attached code produces an error, enter error for the blank.
Answer Point Value: 1.0 points Answer Key: 15
How many times does the loop execute in the attached code? Attachments
Answer Point Value: 1.0 points Answer Key: C
What symbol is used to decorate a function?
Answer Point Value: 1.0 points Answer Key: A
What is the result of the attached code? Attachments
Answer Point Value: 1.0 points Answer Key: A
Which of the following represents a blueprint/template? A. Object B. Class C. Method D. Instance
Answer Point Value: 1.0 points Answer Key: B
What is the result of the attached code? Attachments
A. BlueOrangeGreen B. BlueGreenOrange C. GreenOrangeGreen D. OrangeGreenBlue
B. iter C. generate D. class
Answer Point Value: 1.0 points Answer Key: A
____ are independent of classes, whereas ____ are not. Answer Point Value: 2.0 points Answer Key: Functions, Methods
All methods are functions but not all functions are methods. True False
Answer Point Value: 1.0 points Answer Key: True
Iterators store 1 value at a time in memory. True False
Answer Point Value: 1.0 points Answer Key: True
What error does Python raise when there is no next value? A. NoNext Error B. Type Error C. Iteration Error D. StopIteration Error
Answer Point Value: 1.0 points Answer Key: D
What is the output of the attached code? Attachments
Answer Point Value: 1.0 points Answer Key: B
Which of the following gives the output as the cubes of the values from 1 to 10, including 10. A. [3x for x in range(1,11)] B. [x3 for x in range(10)] C. [x3 for x in range(1,11)] D. [3x for x in range(1,10)]
Answer Point Value: 1.0 points Answer Key: C
Which of the following can be used as keys for dictionaries? A. Dictionaries B. Sets C. Lists D. Tuples
Answer Point Value: 1.0 points Answer Key: D
Dictionaries allow for duplicate keys and values.