CMPUT174 Midterm: CMPUT174 Midterm 2014 Fall with Solution

163 views14 pages
ceruleanzebra152 and 30 others unlocked
CMPUT174 Full Course Notes
25
CMPUT174 Full Course Notes
Verified Note
25 documents

Document Summary

Do not turn this page until you have received the signal to start. Please write your student id on the top right corner of each page. Answer all questions in the space provided; if you require more space, continue on the back of the page. No other notes or books, and no electronic devices of any kind (ie. no cell phones, calculators, etc). Specify all output produced by the program if it runs successfully, or indicate the behaviour if the program does not nish running successfully. a) b) c) The following code snippet is supposed to take a list of numbers and replace each negative value in the list with 0. For example, the list [1, -3, 5, -8] should become [1, 0, 5, 0]. Unfortunately, the code does not work. for number in number_list: if number < 0: number = 0 print(number_list) Rewrite the code so that it works correctly.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents