Podcast
Questions and Answers
How many times will the loop run in the following code? for x in range(3, 17, 2): print(x)
How many times will the loop run in the following code? for x in range(3, 17, 2): print(x)
- 14
- 3
- 7 (correct)
- 5
The line 'if my_list:' in the function 'find_depth' checks if the list is empty.
The line 'if my_list:' in the function 'find_depth' checks if the list is empty.
True (A)
What does the recursive call in the function 'find_depth' do?
What does the recursive call in the function 'find_depth' do?
It calls itself with a sublist to calculate the depth.
In the expression not(my_int % 2)
, 'not' checks if the result is _____ .
In the expression not(my_int % 2)
, 'not' checks if the result is _____ .
Match the following programming concepts with their definitions:
Match the following programming concepts with their definitions:
Which line in the function 'find_depth' contains the recursive call?
Which line in the function 'find_depth' contains the recursive call?
The expression not(my_int % 2)
will return true when my_int
is odd.
The expression not(my_int % 2)
will return true when my_int
is odd.
What is the primary purpose of using a loop in programming?
What is the primary purpose of using a loop in programming?
What will the output of the following code be? print( composers.get("Scriabin", "Who?!") )
What will the output of the following code be? print( composers.get("Scriabin", "Who?!") )
The statement composers['Scarlatti'] = 17 will raise an error if 'Scarlatti' is not already a key in the dictionary.
The statement composers['Scarlatti'] = 17 will raise an error if 'Scarlatti' is not already a key in the dictionary.
What is the output of print(composers["Chopin"], composers["Beethoven"], composers["Vivaldi"]) if composers is defined as given?
What is the output of print(composers["Chopin"], composers["Beethoven"], composers["Vivaldi"]) if composers is defined as given?
The number 64 in binary is represented as __________.
The number 64 in binary is represented as __________.
Match the decimal numbers with their corresponding binary conversions:
Match the decimal numbers with their corresponding binary conversions:
Which statement correctly evaluates if a list named scotsmen is non-empty and a variable ship_of_theseus has at least 12 elements?
Which statement correctly evaluates if a list named scotsmen is non-empty and a variable ship_of_theseus has at least 12 elements?
The binary number 1101 1011 is equivalent to the decimal number 219.
The binary number 1101 1011 is equivalent to the decimal number 219.
Convert the decimal number 183 to hexadecimal.
Convert the decimal number 183 to hexadecimal.
The code snippet print("\\\nMerry\nChristmas!\")
will output "Merry
Christmas!".
The code snippet print("\\\nMerry\nChristmas!\")
will output "Merry
Christmas!".
What does the code print(the_list)
output after executing list_add(the_list)
twice, given the_list = ['1', '7']
?
What does the code print(the_list)
output after executing list_add(the_list)
twice, given the_list = ['1', '7']
?
In the code a_list = ['Python', 'is', 'a', 'fun', 'time']
, the expression a_list[4:10]
outputs ___________.
In the code a_list = ['Python', 'is', 'a', 'fun', 'time']
, the expression a_list[4:10]
outputs ___________.
Match the following functions with their expected output:
Match the following functions with their expected output:
What is the result of three_plus_one(1)
?
What is the result of three_plus_one(1)
?
The function rec_fun(5)
produces an output containing only the letter 'a'.
The function rec_fun(5)
produces an output containing only the letter 'a'.
When the following matrix code is run, what is printed? the_matrix = [[4, 2, 7], [8, 5, 6], [9, 1, 3]]; print(the_matrix)
When the following matrix code is run, what is printed? the_matrix = [[4, 2, 7], [8, 5, 6], [9, 1, 3]]; print(the_matrix)
Flashcards
Loop iterations for range(3, 17, 2)
Loop iterations for range(3, 17, 2)
The range(3, 17, 2)
function generates numbers starting at 3, incrementing by 2, up to (but not including) 17. This results in a sequence of numbers: 3, 5, 7, 9, 11, 13, 15. Therefore the loop will execute 7 times.
Recursive call line in find_depth
function
Recursive call line in find_depth
function
The line of code d = 1 + find_depth(sublist)
within the find_depth
function constitutes a recursive function call; this function calls itself with a smaller input to complete the task based on the defined conditions.
When not(my_int % 2)
is True
When not(my_int % 2)
is True
The expression not(my_int % 2)
evaluates to True when my_int
is an even number. The modulo operator (%
) returns the remainder of a division—if the remainder is 0, it's even (divisible by 2).
Academic dishonesty
Academic dishonesty
Signup and view all the flashcards
Boolean Expression: Non-empty list and list length
Boolean Expression: Non-empty list and list length
Signup and view all the flashcards
Boolean Expression: String comparison and list size
Boolean Expression: String comparison and list size
Signup and view all the flashcards
Dictionary: Accessing non-existent key
Dictionary: Accessing non-existent key
Signup and view all the flashcards
Dictionary: Using the 'get' method
Dictionary: Using the 'get' method
Signup and view all the flashcards
Dictionary: Modifying Value
Dictionary: Modifying Value
Signup and view all the flashcards
Decimal to Binary Conversion
Decimal to Binary Conversion
Signup and view all the flashcards
Decimal to Hexadecimal Conversion
Decimal to Hexadecimal Conversion
Signup and view all the flashcards
Binary to Decimal Conversion
Binary to Decimal Conversion
Signup and view all the flashcards
Hexadecimal to Binary Conversion
Hexadecimal to Binary Conversion
Signup and view all the flashcards
Binary Representation of FD30A15E
Binary Representation of FD30A15E
Signup and view all the flashcards
String Escape Sequences
String Escape Sequences
Signup and view all the flashcards
Output of 'print(\\nMerry\nChristmas!\)'
Output of 'print(\\nMerry\nChristmas!\)'
Signup and view all the flashcards
Modifying a List Inside a Function
Modifying a List Inside a Function
Signup and view all the flashcards
List Slicing Syntax
List Slicing Syntax
Signup and view all the flashcards
Recursive Function with Base Case
Recursive Function with Base Case
Signup and view all the flashcards
Function with Nested If Statements and Recursion
Function with Nested If Statements and Recursion
Signup and view all the flashcards
Study Notes
Exam Information
- Course: CMSC 201
- Semester: Fall 2024
- Exam Type: Practice Final Exam
- Total Points: 165 points (5 extra points)
- Discussion Sections: Students are assigned to a discussion section (numbers listed)
Exam Instructions
- Name: Write your name neatly on the exam.
- Login ID: Use your UMBC email ID without the "@umbc.edu" portion.
- Pencil: The exam must be completed using a pencil.
- Name on Every Page: Write your name at the top of every page.
Undergraduate Honors Statement
- Academic Honesty: Students agree to uphold the highest standards of academic honesty in the course.
- Academic Dishonesty: Cheating, fabrication, plagiarism, and assisting others in committing academic dishonesty is prohibited.
- Academic Integrity: Students agree to abide by the University's and course's academic integrity policies.
Multiple Choice
- Format: Multiple choice questions with bubbles for the correct answer.
- Points: 3 points per question
- Total Points: 30 points (3 points each)
- Instructions: Clearly and cleanly fill in the bubbles for the selected option.
Additional Questions
- Recursive Call: A recursive call in a function is specified.
- Mutable vs Immutable Types: Lists are mutable data types that are passed by reference.
- Error: A type error is described, and its cause is explained.
- Boolean Expressions: Boolean expressions evaluate to True or False. Students must write correct boolean expressions.
- Dictionary Evaluation: Students are required to provide the results of dictionary operations, recognizing any errors.
Binary, Hexadecimal & Decimal
- Conversions: Convert numbers between binary, hexadecimal, and decimal formats.
- Decimal to Binary/Hexadecimal: Work for conversions of integers
- Binary/Hex to Decimal: Work for conversions of given values
Code Evaluation
- Programming Concepts: Evaluates code snippets and their outputs.
- Formatted Output: Output formatting is a consideration in evaluating code.
Debugging
- Errors: Find and correct five errors in given code snippets.
- Recursive function: Creating function for binary number operations and vowel counting.
- Debugging (Part 2): Find, and fix errors for a second set of code.
Programming Problems
- 2D Lists: Finding minimum of maximum in 2-dimensional lists
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Prepare for your CMSC 201 final exam with this practice test designed for Fall 2024. The exam evaluates your understanding of course material through multiple-choice questions. Ensure you follow the exam instructions carefully for successful completion.