CMSC 201 Fall 2024 Practice Final Exam
23 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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.

    True

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

    <p>zero</p> Signup and view all the answers

    Match the following programming concepts with their definitions:

    <p>Loop = A block of code that repeats a certain number of times Recursive call = A function that calls itself Data structure = A way of organizing and storing data Algorithm = A step-by-step procedure for solving a problem</p> Signup and view all the answers

    Which line in the function 'find_depth' contains the recursive call?

    <p>Line 5</p> Signup and view all the answers

    The expression not(my_int % 2) will return true when my_int is odd.

    <p>False</p> Signup and view all the answers

    What is the primary purpose of using a loop in programming?

    <p>To execute a block of code repeatedly as long as a condition is true.</p> Signup and view all the answers

    What will the output of the following code be? print( composers.get("Scriabin", "Who?!") )

    <p>Who?!</p> Signup and view all the answers

    The statement composers['Scarlatti'] = 17 will raise an error if 'Scarlatti' is not already a key in the dictionary.

    <p>False</p> Signup and view all the answers

    What is the output of print(composers["Chopin"], composers["Beethoven"], composers["Vivaldi"]) if composers is defined as given?

    <p>24 9 4</p> Signup and view all the answers

    The number 64 in binary is represented as __________.

    <p>1000000</p> Signup and view all the answers

    Match the decimal numbers with their corresponding binary conversions:

    <p>64 = 1010000 183 = 00010111</p> Signup and view all the answers

    Which statement correctly evaluates if a list named scotsmen is non-empty and a variable ship_of_theseus has at least 12 elements?

    <p>len(scotsmen) &gt; 0 and len(ship_of_theseus) &gt;= 12</p> Signup and view all the answers

    The binary number 1101 1011 is equivalent to the decimal number 219.

    <p>True</p> Signup and view all the answers

    Convert the decimal number 183 to hexadecimal.

    <p>B7</p> Signup and view all the answers

    The code snippet print("\\\nMerry\nChristmas!\") will output "Merry Christmas!".

    <p>False</p> Signup and view all the answers

    What does the code print(the_list) output after executing list_add(the_list) twice, given the_list = ['1', '7']?

    <p>['1', '7', '3', '3']</p> Signup and view all the answers

    In the code a_list = ['Python', 'is', 'a', 'fun', 'time'], the expression a_list[4:10] outputs ___________.

    <p>[]</p> Signup and view all the answers

    Match the following functions with their expected output:

    <p>print(a_list[2:4]) = ['a', 'fun'] print(a_list[4:10]) = [] print(a_list[:3]) = ['Python', 'is', 'a'] hello(15) = prints 'hello' multiple times</p> Signup and view all the answers

    What is the result of three_plus_one(1)?

    <p>4</p> Signup and view all the answers

    The function rec_fun(5) produces an output containing only the letter 'a'.

    <p>False</p> Signup and view all the answers

    When the following matrix code is run, what is printed? the_matrix = [[4, 2, 7], [8, 5, 6], [9, 1, 3]]; print(the_matrix)

    <p>[[4, 2, 7], [8, 5, 6], [9, 1, 3]]</p> Signup and view all the answers

    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.

    Quiz Team

    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.

    More Like This

    Use Quizgecko on...
    Browser
    Browser