Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1. This is a MULTIPLE ANSWER question, which means you are able to select one or more answers as being correct. Note that this does

Q1. 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 aremultiple 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?

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Q2.

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 thereare 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 results. Which of the following blocks of Python code would cause every value in the list results to be printed?

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Q3.

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 thereare 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 Python documentation as follows:

open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)

Which of the following 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

Q4.

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.

1. True

2. False

Q5.

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 = []

insert a answer

insert a answer

insert a answer

return new_list

Choose only one in each insert a answer

1. num = num+2

2. new_list+ = num

3. new_list = num

4. new_list.append(num)

5. for num in range(items):

6. for index in range(len(items)):

7. for num in items:

8. for num % 2 ==0:

9. if index % 2 ! = 0:

10. if index % 2 == 0:

11. if num % 2 ! = 0:

12. if num % 2 == 0:

13. if num == 2:

14. if index == 2:

15. if num % 2 = 0:

16. num % 2 == 0

17. items += [num]

18. items.append(num)

19. items.append(items[num])

20. new_list.append(items[num])

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

=+how might their legitimacy be improved?

Answered: 1 week ago