Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

14. Which of the following is the correct way to open a file named users.txt in

ID: 3600455 • Letter: 1

Question

14. Which of the following is the correct way to open a file named users.txt in 'r' mode? users.txt) b. infile readCusers.txt'. T) infile t open('users.txt', 'r') a. infi infile readlines(users.txtr) 15. What will be the output after the following code the first two prompts? executed and the user enters def mainO: try: total = int(input("Enter total cost of items? ")) num items int(input("Number of items)) average = total / num-items except ZeroDivisionError: print('ERROR: cannot have 0 items') except ValueError: printC'ERROR: number of items cannot be negative) mainO -t ERROR: number of items can't be negative -d. Nothing; there is no print statement to display average. 16. What will be the output after the following code is executed and the use the first two prompts? def mainO: try: total = int(input("Enter total cost of items? ")) num-items = int(input("Number of items ")) average = total / num-items except ZeroDivisionError: print('ERROR: cannot have 0 items') except ValueError: print('ERROR: number of items cannot be negative') main) a. ERROR: cannot have,0items b. ERROR: cannot haveO items ERROR: number of items can't be negative- c. ERROR: number of items can't be negative Nothing; there is no print statement to display a catch the error.

Explanation / Answer

Question 14
Answer: c. infile = open("users.txt", "r");

Question 15
Answer: a. Error: cannot have 0 items

Question 16
Answer: d. there is no print statement to display

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote