Knowee
Questions
Features
Study Tools

Step 1 (3 pts). Complete the CheckSingles() function. Return the sum of all values that match parameter goal. Update the FindHighScore() function using a loop to call CheckSingles() six times with parameters being 1 - 6. Return the highest score from all function calls. Submit for grading to confirm two tests pass.Ex: If input is:2 4 1 5 4the output is:High score: 8

Question

Step 1 (3 pts). Complete the CheckSingles() function. Return the sum of all values that match parameter goal. Update the FindHighScore() function using a loop to call CheckSingles() six times with parameters being 1 - 6. Return the highest score from all function calls. Submit for grading to confirm two tests pass.Ex: If input is:2 4 1 5 4the output is:High score: 8

🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a Python solution for your problem:

def CheckSingles(lst, goal):
    return sum(i for i in lst if i == goal)

def FindHighScore(lst):
    return max(CheckSingles(lst, i) for i in range(1, 7))

# Test the function
print("High score:", FindHighScore([2, 4, 1, 5, 4]))

In the CheckSingles function, we are using list comprehension to sum all the values in the list that match the goal.

In the FindHighScore function, we are using a generator expression to call CheckSingles for each number from 1 to 6, and then we use the max function to find the highest score among these.

This problem has been solved

Similar Questions

Create a function of name check_marks(). The function will receive two marks. The function should add these two marks and return “Pass” if the sum is greater than or equal to 60 and return “Fail” if the sum is less than 60.For example, if the marks are 39 and 45, then the function return "Pass" because the sum of 39 and 45 is 84 which is greater than 60.

Try the following code. Add an else statement to the if statement that prints out “Good job!” if the score is greater than 9. Change the value of score to test it. Can you change the boolean test to only print out “Good job” if the score is greater than 20?Save & RunOriginal - 1 of 1Show CodeLensReformat1public class ScoreTest2{3 public static void main(String[] args)4 {5 int score = 8;6 if (score <= 9)7 {8 System.out.println("Try for a higher score!");9 }10 }11}12​13​Try for a higher score!Result Expected Actual NotesFail true false Checking for score <= 20 or score > 20Fail Good job! Checking output if score is 25Pass Try for a higher score! Try for a higher score! Checking output if score is 5Fail true false Checking that code contains elseFail true false Checking that code has been changed

Michael took 12 tests in his math class. His lowest test score was 78. His highest test score was 98. On the 13th test, he earned a 64. Select whether the value of each statistic for his test scores increased, decreased, or could not be determined when the last test score was added.

Grade AnalyzerYou have a class consisting of 5 students, each with a unique name and their respective marks. As the end of the semester approaches, you decide to assess the performance of your students and recognize their academic achievements.You write a Python program to categorize the students into different grades based on their marks. The program utilizes a Grade_analyzer class to represent each student and a StudentGradeAnalyzer function to analyze their grades. The function iterates through the list of students, calculates their grades and returns a dictionary containing the count of students in each grade.For grading:Students scoring between 80-100 will be in Grade A.Students scoring between 70-80 will be in Grade B.Students scoring between 60-70 will be in Grade C.Students scoring between 50-60 will be in Grade D.Students scoring below 50 will be in Grade E.Constraints:Input Format:5 lines of input, each line containing name and marks of each student.Ouptut Format:Should display items in dictionary which is holding Grades as keys and count of students falling under the grades as values.Example:Input:john 78missy 89sheldon 90mary 45meemaw 67Output:('A', 2)('B', 1)('C', 1)('D', 0)('E', 1)Explanation:input:--------Space saperated input name and marks for all the 5 students.john 78-->78 Falls into a range 70-80 so count of grade 'B' should be increased to 1.missy 89-->89 Falls into a range 80-100 so count of grade 'A' should be increased to 1.sheldon 90-->90 Falls into a range 80-100 so count of grade 'A' should be increased to 2.mary 45-->45 is less than 50 so count of grade 'E' should be increased to 1.meemaw 67-->67 Falls into a range 60-70 so count of grade 'C' should be increased to 1.Output:--------Output should a dict which will hold how many students are falling into each grade.{'A': 2, 'B': 1, 'C': 1, 'D': 0, 'E': 1}Output will be printing each item in dict as a tuple. Public Test Cases:# INPUT EXPECTED OUTPUT1 john 78missy 89sheldon 90mary 45meemaw 67('A', 2) ('B', 1) ('C', 1) ('D', 0) ('E', 1)

Grade AnalyzerYou have a class consisting of 5 students, each with a unique name and their respective marks. As the end of the semester approaches, you decide to assess the performance of your students and recognize their academic achievements.You write a Python program to categorize the students into different grades based on their marks. The program utilizes a Grade_analyzer class to represent each student and a StudentGradeAnalyzer function to analyze their grades. The function iterates through the list of students, calculates their grades and returns a dictionary containing the count of students in each grade.For grading:Students scoring between 80-100 will be in Grade A.Students scoring between 70-80 will be in Grade B.Students scoring between 60-70 will be in Grade C.Students scoring between 50-60 will be in Grade D.Students scoring below 50 will be in Grade E.Constraints:Input Format:5 lines of input, each line containing name and marks of each student.Ouptut Format:Should display items in dictionary which is holding Grades as keys and count of students falling under the grades as values.Example:Input:john 78missy 89sheldon 90mary 45meemaw 67Output:('A', 2)('B', 1)('C', 1)('D', 0)('E', 1)Explanation:input:--------Space saperated input name and marks for all the 5 students.john 78-->78 Falls into a range 70-80 so count of grade 'B' should be increased to 1.missy 89-->89 Falls into a range 80-100 so count of grade 'A' should be increased to 1.sheldon 90-->90 Falls into a range 80-100 so count of grade 'A' should be increased to 2.mary 45-->45 is less than 50 so count of grade 'E' should be increased to 1.meemaw 67-->67 Falls into a range 60-70 so count of grade 'C' should be increased to 1.Output:--------Output should a dict which will hold how many students are falling into each grade.{'A': 2, 'B': 1, 'C': 1, 'D': 0, 'E': 1}Output will be printing each item in dict as a tuple.

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.