Question

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 their grades.


Example Execution:
Enter a student name: "MaryJo"
Enter a Grade for MaryJo: 88
Enter a Grade for MaryJo: 71
Enter a Grade for MaryJo: 90
Enter a Grade for MaryJo: done
Do you want to add another student: yes
Enter a student name: "Jim"
Enter a Grade for Jim: 85
Enter a Grade for Jim: 89
Enter a Grade for Jim: no
Do you want to add another student: No
Student Stats: MaryJo (71 -90): 83 Jim (85 -89): 87
  

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

Explanation::

  • Code in python is given below
  • Screenshot of code is also provided
  • Output is given at the end of the code

Code in PYTHON::

import statistics
'''
First we declare an dictionary named studentData
Where key will be name and value will be list of grades
'''
studentGrade = {}
'''
Using while loop we continue asking if user wants to
add student or no
'''
while True:
    name = input("Enter a student name:")
    name = name.strip('"')
    if name not in studentGrade.keys():
        studentGrade[name]=[]
    while True:
        print('Enter a Grade for ',name,':',end='',sep='')
        grade = input()
        if grade.isdigit():
            studentGrade[name].append(int(grade))
        else:
            break
    add = input("Do you want to add another student:").lower()
    if add=='no':
        break
print('Student stats: ',end='',sep='')
for name, grade in studentGrade.items():
    minimum = min(grade)
    maximum = max(grade)
    meanValue = statistics.mean(grade)
    print(name,' (',minimum,'-',maximum,'):',meanValue,' ',end='',sep='')
print()

Screenshot of the code:

import statistics First we declare an dictionary named studentData Where key will be name and value will be list of grades st22 name = input(Enter a student name:) name = name.strip() if name not in studentGrade.keys(): studentGrade[name]=[] whil

OUTPUT:

DIE DOOD Enter a student name: Maryjo Enter a Grade for Mary Jo: 88 Enter a Grade for Maryjo: 71 Enter a Grade for Maryjo:90

Please provide the feedback!!

Thank You!!

Add a comment
Know the answer?
Add Answer to:
Write a program that asks the user for a student name and asks for grades until...
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
  • 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 asks for 'name from the user and then asks for a number...

    Write a program that asks for 'name from the user and then asks for a number and stores the two in a dictionary [called the_dicr) as key-value pair. The program then asks if the user wants to enter more data [More data ly/n]?) and depending on user choice, either asks for another name-number pair or exits and stores the dictionary key, values in a list of tuples and prints the list Note: Ignore the case where the name is already...

  • Write a program that prompts the user for student grades and displays the highest and lowest grades in the class.

    Write a program that prompts the user for student grades and displays the highest and lowest grades in the class. The user should enter a character to stop providing values.example Enter as many student grades as you like. Enter a character to stop. The highest grade is: 92.0 The lowest grade is: 10.65# in java

  • PYTHON PROGRAMMING Instructions: You are responsible for writing a program that allows a user to do...

    PYTHON PROGRAMMING Instructions: You are responsible for writing a program that allows a user to do one of five things at a time: 1. Add students to database. • There should be no duplicate students. If student already exists, do not add the data again; print a message informing student already exists in database. • Enter name, age, and address. 2. Search for students in the database by name. • User enters student name to search • Show student name,...

  • Write C++ program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the...

    Write C++ program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the user to enter a number and based on the entered number it allocates the array size. Then based on that number it asks the user that many times to enter student’s names. What you need to do:  Add another array of doubles to store the gpa of each student as you enter them  You need to display both the student’s name and...

  • Write a JAVA program that prompts the user for student grades and displays the highest and...

    Write a JAVA program that prompts the user for student grades and displays the highest and lowest grades in the class. The user should enter a character to stop providing values. Starter code: import java.util.Scanner; public class MaxMinGrades{   public static void main(String[] args){     Scanner input = new Scanner(System.in);     System.out.println("Enter as many student grades as you like. Enter a character to stop.");     double grade = input.nextDouble();     double minGrade = Double.MAX_VALUE;     double maxGrade = Double.MIN_VALUE;     while (Character.isDigit(grade)) {       if (grade == 0)...

  • In this assignment, you will write a program in C++ which uses files and nested loops...

    In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...

  • Write a program that prompts the user for student grades, calculates and displays the average grade...

    Write a program that prompts the user for student grades, calculates and displays the average grade in the class. The user should enter a character to stop providing values.

  • using C# Write a program which calculates student grades for multiple assignments as well as the...

    using C# Write a program which calculates student grades for multiple assignments as well as the per-assignment average. The user should first input the total number of assignments. Then, the user should enter the name of a student as well as a grade for each assignment. After entering the student the user should be asked to enter "Y" if there are more students to enter or "N" if there is not ("N" by default). The user should be able to...

  • in c++ A: Write a program which ask user to enter 10 student's name and their...

    in c++ A: Write a program which ask user to enter 10 student's name and their grades. Then find the average of all the grades. Output all the grades with student name of whom got the grade over the average.

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
ADVERTISEMENT