Soru
Part 1 (30pts): Define a Python function called getQulizes() that takes an integer N as parameter. This function will prompt the user to Input N quiz scores and add them to a list and return the list when done. Write Python statements that input the number of quizzes, call this function and print the returned list as seen in sample run below. Part 1: piên so onter 3 so thế scoro of quike 20 Plas so ntar the score quiz-2: 90 Plea so entor score quiz-3. 85 Your s cores are stored in the following list: [20,90,85]
Çözüm
4.5
(286 Oylar)
Ceyda
Kıdemli · 12 yıl öğretmeni
Uzman doğrulaması
Cevap
Here is the Python function `getQuizzes()` that takes an integer `N` as a parameter, prompts the user to input `N` quiz scores, adds them to a list, and list when done:```pythondef getQuizzes(N): quizzes = [] for i in range(N): score = int(input(f"Please enter the score for quiz {i+1}: ")) quizzes.append(score) return quizzes```To input the number of quizzes, call this function, and print the returned list, you can use the following Python statements:```pythonN = int(input("Enter the number of quizzesquizzes = getQuizzes(N)print("Your scores are stored in the following list:", quizzes)```Sample run:```pythonEnter the number of quizzes: 3Please enter the score for quiz 1: 20Please enter the score for quiz 2: 90Please enter the score for quiz 3: 85Your scores are stored in the following list: [20, 90, 85]```