Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is a MULTIPLE ANSWER question, which means you are able to select one or more answers as being correct. Note that this does not
This is a MULTIPLE ANSWER question, which means you are able to select one or more answers as being correct. Note that this does not necessarily mean that there are multiple correct answers. In any case, select all the answers you believe are correct. (NB: There are no part marks awarded for multiple answer questions.) There is a Python list of integers called rainfall. Which of the following blocks of code would find the average of the integers contained in rainfall? for amount in rainfall: sum- 0 sum = + amount erage sum // len (raintal1) for amount in rainfall: sum-amount average = sum // len (rainfall) sum = 0 for amount in rainfall: sumsum +amount average-sum // len (rainfall) f r amount in rainfall: sumSum + amount average-sum // len (rainfall) for amount in rainfall: umumamount average-sum // len (rainfall) for amount in rainfall: sum amount average- sum // len (rain QUESTION 2 This is a MULTIPLE ANSWER question, which means you are able to select one or more answers as being correct. Note that this does not necessarily mean that there are multiple correct answers. In any case, select all the answers you believe are correct (NB: There are no part marks awarded for multiple anaw er questions.) There is a Python list of integers called results. Which of the following blocks of Python codewould cause every value in the list results to be printed? or secret_thing in results: print (secret_thing) for secret location in range (len (results)) print (secret location) for secret_location in range (len (results) -1): print (secret location) for secret location in range (len (results)): print (results [secret location]) for secret in results: print (secret) QUESTION 3 This is a MULTIPLE ANSWER question. which means you are able to select one or more answers as being correct. Note that this does not necessarily mean that there are multiple correct answers. In any case, select all the answers you believe are correct NB: There are no part marks awarded for multiple answer questions.) This question is designed to test your ability to find and interpret Python documentation There is a Python function shown in the Fython documentation as follows open (file, mode=' r, buffering=-1, encoding=None, errors-None, newline-None, closefa-True, opener=None) Which of the follow ing are built-in functions (methods) that can be used on the value that is returned from a successful call to the open function (assuming the appropriate mode is used)? close read. seek tell write QUESTION 4 This question is designed to test your ability to find and interpret Python documentation. There is a built-in Python function which can be used to open a file. It is shown in the Python documentation as follows: open (file, mode-r', buffering--1, encoding-None, errors-None, newline-None, closefd-True, opener-None,) Is the following statement true or false? Using the open function, it is possible to open a file for reading or writing, but not both True False QUESTION 5 Consider a Python function called get_evens that expects as an argument a list of numeric values. YOUR TASK is to complete the function body below so that, when run, it extracts all of the even numbers contained in the list variable items, and returns a list of those even numbers NB: The % operator returns the remainder after integer division. def get_evens (items): new list [ return new 1ist open (fil num-num+ ng-None, errors=None, newline-None, closetd-True, opener=None) 2 Is the follow ing etate new list+num new list = num Using the op new _list.append(num) eading orriting, but not both True for num in range(items): for index in range(len(items)): for num in items: for num % 2-0: if index % 2-0: if index % 2-0: ifnum % 2 != 0: ifnum % 2-0: if num 2: False QUESTION5 Consider a Python fl if index argument a list of numeric values 2: YOUR TASK is to cc ifnum % 2 = 0: even numbers n run, it extracts all of the even numbers contained in the list variable items, and returns a list of those num % 2-0 NB: The % operator items +-[num] def tems.append(num) items.append(items[num]) return new_list
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started