SampleExample2023-2

.pdf

School

University of Michigan *

*We aren’t endorsed by this school

Course

106

Subject

Computer Science

Date

Apr 3, 2024

Type

pdf

Pages

8

Uploaded by BailiffStrawMeerkat43 on coursehero.com

SI106 Exam Fall 2023 Name: ___________________________ Unique name: __________________________ THIS IS A LONG TEST. There are 27 questions and each question is worth 4pts unless noted otherwise in the question. There are a total of 110 points. 90 points is 100%. The max score is 100 points, so you can get some extra credit. Answer the questions as carefully and (when applicable) as concisely as you can. There will be deductions for missing key components in your answer. There will also be deductions if you include information that is not true. WRITE NEATLY IN THE ANSWER BOXES PROVIDED. READ THE QUESTIONS CAREFULLY. If you are unsure about a question, you can write your assumptions to the side but we will not be taking questions during the quiz. 1. What is the return type of .split()? 2. What is the return type of .join()? 3. What is the return type of .isupper()? 4. What is the return type of .append()? 5. What is the return type of .items()?
6. What is the return type of .read()? 7. What is the return type of .readlines()? I am going to list common error types here to help you with Q8-12 SyntaxError, NameError, AttributeError, TypeError, KeyError, AssertionError, IndexError, ZeroDivisionError 8. What type of error is returned in the following code? my_list = [1,2,3,4,5] print(my_list[5]) 9. What type of error is returned in the following code? my_list = [1,2,3,4,5] print(my_list.split("!")) 10.What type of error is returned in the following code? my_list = [1,2,3,4,5] assert len(my_list) == 10 11.What type of error is returned in the following code? my_dict = {} print(my_dict[1]) 12.What type of error is returned in the following code? num_str = "1 # 2 # -34" for num in num_str.split('#'): product *= int(num)
Questions 13 - 17 do not generate errors 13.What is the output of the following code snippet? words = ['the', 'quick', 'brownish', 'fox', 'jumped'] count = 0 for word in words: if len(word) >= 5: count += 1 print(count) 14.What is the output of the following code snippet? words = ['the', 'quick', 'brownish', 'fox', 'jumped'] for word in words: count = 0 if len(word) > 4: count += 1 print(count) 15.What is the output of the following code snippet? my_list = ["cat","dog","fish"] for i in range(len(my_list)): print(i)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help