Question

### Question in python code, write the code on the following program: def minmaxgrades(grades, names): """...

### Question in python code, write the code on the following program:


def minmaxgrades(grades, names):
"""
Computes the minimum and maximujm grades from grades and creates a list of
two student names: first name is the student with minimum grade and second
name is the student with the maximum grade.
grades: list of non-negative integers
names: list of strings
Returns: list of two strings
"""

def main():
"""
Test cases for minmaxgrades() function
"""
input1 = [80, 75, 90, 85, 100, 95]
input2 = ['ann', 'bob', 'sam', 'max', 'dan', 'art']
return_value = minmaxgrades(input1, input2)
print(f'{return_value}')

if __name__ == '__main__':
main()

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please let me know if you need more information:-

============================================

### Question in python code, write the code on the following program:


def minmaxgrades(grades, names):

#"""

#Computes the minimum and maximujm grades from grades and creates a list of

#two student names: first name is the student with minimum grade and second

#name is the student with the maximum grade.

#grades: list of non-negative integers

#names: list of strings

#Returns: list of two strings

#"""

list_result = ["",""]

min_val = grades[0]

max_val = grades[0]

i=0

for grade in grades:

if min_val > grade:

min_val = grade

list_result[0] = names[i]

if max_val<grade:

max_val = grade

list_result[1] = names[i]

i+=1

return list_result



def main():

#"""

#Test cases for minmaxgrades() function

#"""

input1 = [80, 75, 90, 85, 100, 95]

input2 = ['ann', 'bob', 'sam', 'max', 'dan', 'art']

return_value = minmaxgrades(input1, input2)

print(f'{return_value}')

if __name__ == '__main__':

main()

==================

1 ### Question in python code, write the code on the following program: [bob, dan] def minmaxgrades (grades, names): 6 #C

=================

OUTPUT;-

===

['bob', 'dan']

====

Please let me know if you need more information:-

==

Thanks

Add a comment
Know the answer?
Add Answer to:
### Question in python code, write the code on the following program: def minmaxgrades(grades, names): """...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What's wrong with this Python code? def scale_midterm_grades(grades: List[float], multiplier: float, bonus: float) -> None:   ...

    What's wrong with this Python code? def scale_midterm_grades(grades: List[float], multiplier: float, bonus: float) -> None:    """Modify each grade in grades by multiplying it by multiplier and then adding bonus. Cap grades at 100.    >>> grades = [45, 50, 55, 95]    >>> scale_midterm_grades(grades, 1, 10)    >>> grades    [55, 60, 65, 100]    """    for grade in grades:        grade = grade*multiplier + bonus        if grade > 100:            grade =...

  • I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import...

    I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import arithmetic as a def multiply(num1, num2):     product = num1 * num2     result = a.add(product, product)     return result     def main():     num1 = 4     num2 = 3     answer = multiply(num1, num2)     print("The answer is", answer) if __name__ == "__main__":     main() arithmetic module: def add(x, y):     z = x + y     return z Refer to Code...

  • write a code that includes the following:(PYTHON NOT JAVA) # This program uses the writelines method...

    write a code that includes the following:(PYTHON NOT JAVA) # This program uses the writelines method to save # a list of strings to a file. def main(): # Create a list of strings. # Open a file for writing. # Write the list to the file. # Close the file. # Call the main function.

  • Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and...

    Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and his/her course names with grades. ? Your system should allow the user to input, update, delete, list and search students’ grades. ? Each student has a name (assuming no students share the same name) and some course/grade pairs. If an existing name detected, user can choose to quit or to add new courses to that student. ? Each student has 1 to 5 courses,...

  • Write a program that does the following in Python Code: Write a new Class called Famous_Day_Born...

    Write a program that does the following in Python Code: Write a new Class called Famous_Day_Born which is a subclass of Famous_Person. Add a method to calculate the day of the week the person was born and print out all of the corresponding information using the overridden print method. Use the following code below as a starting point. ////////////////////////////////////////////////////// from datetime import datetime class Famous_Person(object): def __init__(self, last, first, month,day, year): self.last = last self.first = first self.month = month...

  • Write a python code that takes in an number 0-9 and prints out the word of...

    Write a python code that takes in an number 0-9 and prints out the word of the number. For example 1 would print out one. Below is the skeleton of the code that needs to be filled in. def num2string(num): """ Takes as input a number, num, and returns the corresponding name as a string. Examples: num2string(0) returns "zero", num2string(1)returns "one" Assumes that input is an integer ranging from 0 to 9 """ numString = "" ################################### ### FILL IN...

  • In python def lambda_1(filename): # Complete this function to read grades from `filename` and find the...

    In python def lambda_1(filename): # Complete this function to read grades from `filename` and find the minimum # student test averages. File has student_name, test1_score, test2_score, # test3_score, test4_score, test5_score. This function must use a lambda # function and use the min() function to find the student with the minimum # test average. The input to the min function should be # a list of lines. Ex. ['student1,33,34,35,36,45', 'student2,33,34,35,36,75'] # input filename # output: (lambda_func, line_with_min_student) -- example (lambda_func, 'student1,33,34,35,36,45')...

  • Write a program that asks the user for a student name and asks for grades until...

    Write a program that asks the user for a student name and asks for grades until the user enters a non-number input, it should then ask if the user wants to enter another student, and keep doing the process until the user stops adding students. The student’s must be stored in a dictionary with their names as the keys and grades in a list. The program should then iterate over the dictionary elements producing the min, max, and mean of...

  • Having trouble with python! Write a program to build a list of grades, print them out,...

    Having trouble with python! Write a program to build a list of grades, print them out, add to them and count occurrences, and find the amount of the 2-digit grade values. Here are the criteria a) Your program “L6QI initials.py" must start with a commented ID Box AND include a comment that indicates the e of the program. EACH of the five functions in your program must state its purpose in comments too The main function in your program must...

  • (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that...

    (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that you have been provided on Canvas. That file has a name and 3 grades on each line. You are to ask the user for the name of the file and how many grades there are per line. In this case, it is 3 but your program should work if the files was changed to have more or fewer grades per line. The name and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT