Write a program that uses the following menu to keep track of student information: 1) Enter a student 2) Quit If the user chooses 1, prompt the user to enter a grade level (to be chosen from the given menu) and a test score. Keep track of the following: • Total number of Freshmen, Sophomores, Juniors, and Seniors • Total number of students entered • Total of all test scores entered When the user chooses to quit, calculate: • The percentage of students that fall into each category • The average of all the test scores entered Display your results as shown. Input validation: • The user must choose valid options from the menus. • The user must enter a test score between 0 and 100.

Question
Asked Nov 9, 2019
1 views

Write a program that uses the following menu to keep track of student information: 1) Enter a student 2) Quit If the user chooses 1, prompt the user to enter a grade level (to be chosen from the given menu) and a test score. Keep track of the following: • Total number of Freshmen, Sophomores, Juniors, and Seniors • Total number of students entered • Total of all test scores entered When the user chooses to quit, calculate: • The percentage of students that fall into each category • The average of all the test scores entered Display your results as shown. Input validation: • The user must choose valid options from the menus. • The user must enter a test score between 0 and 100.

check_circle

Expert Answer

Python program to keep track of student information

Program Intro

Create a menu using printf() function and use while loop to show the menu repeatedly. Create a variable “choice” to input user’s choice between 1 and 2. Create lists grade_level and test_score to store input choices from 1 to 4. Use list grade_level and function len() to show the total number of students. Use sum() function with len() function to calculate average score. Use if-elif conditions to count the number freshman, sophomore, junior and senior students and also their percentage of falling into each category.

Program

print("\nWELCOME TO THE STUDENT SURVEY!!\n")

# lists for keeping track

grade_level = []test_score = []

# menu

while True:

print("\nPlease choose from the following menu:")

print("\t1) Enter Student Information")

print("\t2) Quit")

ch = input("\nEnter your choice here: ")

choice = int(ch)

if choice == 2:      print("Good bye.")    

  break

elif choice != 1: 

     # input validation

print("Invalid selection. You must choose 1 or 2 from the menu.")     

continue print("\nPlease choose the grade level from the following menu:")     

print("\t1) Freshman")  

    print("\t2) Sophomore")     

print("\t3) Junior")   

   print("\t4) Senior")    

  gra = input("\nEnter the grade level here: ")  

    grade = int(gra)   

   grade_level.append(grade)  

    # input validations    

  while True:    

  test_s = input("Enter the test score: ")     

test = int(test_s)   

   if test <0 or test>100:  

    print("Invalid test score. Must be between 0 and 100.\n")    

   else:     

test_score.append(test)   

   break  

    # displaying total students and their average

print("\nTotal number of students entered:\t",len(grade_level))

print("\nAverage test score:\t",sum(test_score)/len(test_score))    

&...

print("nWELCOME TO THE STUCENT SURVEY!!\n" )
lists for keeping track
grade_level = []
test score [).
l nenu
while True
print("nPlease choose from the following menu:")
print("t1) Enter Student Information" )
print("t2) Quit"
ch input(nEnter your choice here: "
choice int(ch)
if choice == 2:
print("Good bye.")
break
1
elif choice
# input validation
print("Invalid selection. You must choose 1 or 2 from the nenu.")
continue
print"nPlease choose the grade level fron the following nenu:)
print("t1) Fres hman ")
print("t2) Sophonore")
print("t3) Junior")
print("t4) Senior")
gra input("nEnter the grade level here: ")
grade int(gra)
grade_level.append (grade)
#input validations
while True:
test_s input ( "Enter the test score: )
test int(test_s)
if test or test>180:
print("Invalid test score. Must be between and 108.\n")
else:
test_score.append (test)
break
l displaying total students and their average
print"nTotal nunber of students entered:\t", len (grade_level))
print"nAverage test score:t" , sum (test_score)/len ( test_score))
print("nPercents: ")
Freshman-
Sophomore-e
Junior-e
Senior-e
a counting the students of different category
it can also be done at the time of input
for elenent in grade_level
if element 1
Freshman+-1
elif elenent -- 2:
Sophomore+ 1
elif elenent 3
Junior-1
elif elenent == 4
Senior+-1
formmating the required result
print("Freshnan: \t\t( : >18.2%)". format (Freshman/len (grade_level))
print("Sophonore : \t\t ( : >10. 2%)". format (Sophomore/len (grade_level)))
print"Junior:\t\t :14.2x ) " .format (Junior/len(grade_level)))
print("Senior: \t\t :14.2x ) " .format (Senior/len(grade_level)))
help_outline

Image Transcriptionclose

print("nWELCOME TO THE STUCENT SURVEY!!\n" ) lists for keeping track grade_level = [] test score [). l nenu while True print("nPlease choose from the following menu:") print("t1) Enter Student Information" ) print("t2) Quit" ch input(nEnter your choice here: " choice int(ch) if choice == 2: print("Good bye.") break 1 elif choice # input validation print("Invalid selection. You must choose 1 or 2 from the nenu.") continue print"nPlease choose the grade level fron the following nenu:) print("t1) Fres hman ") print("t2) Sophonore") print("t3) Junior") print("t4) Senior") gra input("nEnter the grade level here: ") grade int(gra) grade_level.append (grade) #input validations while True: test_s input ( "Enter the test score: ) test int(test_s) if test or test>180: print("Invalid test score. Must be between and 108.\n") else: test_score.append (test) break l displaying total students and their average print"nTotal nunber of students entered:\t", len (grade_level)) print"nAverage test score:t" , sum (test_score)/len ( test_score)) print("nPercents: ") Freshman- Sophomore-e Junior-e Senior-e a counting the students of different category it can also be done at the time of input for elenent in grade_level if element 1 Freshman+-1 elif elenent -- 2: Sophomore+ 1 elif elenent 3 Junior-1 elif elenent == 4 Senior+-1 formmating the required result print("Freshnan: \t\t( : >18.2%)". format (Freshman/len (grade_level)) print("Sophonore : \t\t ( : >10. 2%)". format (Sophomore/len (grade_level))) print"Junior:\t\t :14.2x ) " .format (Junior/len(grade_level))) print("Senior: \t\t :14.2x ) " .format (Senior/len(grade_level)))

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: In MS Access, what kind of data will be accepted into database using theinput mask \A\S\ 00\-99\-A;0...

A: Input mask:Input mask is used to specify what kind of data it will take in database. These are some ...

question_answer

Q: Using DeMorgan's Law, write an expression for the complement of F if F(x,y,z) = xz' (xy + xz)+ xy'(w...

A: Demorgan’s law is a transformation rule in Boolean algebra. According to this rule,Negation of A OR ...

question_answer

Q: In Python Define a function writeScores with two parameters. The first should be the name of a file,...

A: Below is the approach and python code:Approach:Define a function “writeScores” having two parameters...

question_answer

Q: This program is written in pseudocode."Design a program that generates a 7-ddigit lottery number. Th...

A: This pseudocode explains how to create a 7-digit lottery number. These 7 digits are randomly generat...

question_answer

Q: What are the different computer languages? Give a brief description of each.

A: DefinitionLanguage is the basic way of communication between the computer systems and to communicate...

question_answer

Q: Odd man out: . Topological sort Algorithm DFS Algorithm Binary search Algorithm BFS Algorithm Prim's...

A: Answer:Binary Search AlgorithmExplanation:Topological sort Algorithm, DFS algorithm, BFS algorithm a...

question_answer

Q: 4. Given the for loop, rewrite the code so that it executes exactly the same but uses a while loop f...

A: For-loop syntax:             for(initialization ; condition ; updation)                             ...

question_answer

Q: Using Java Eclipse create the following program

A: Below is the approach and java code to create an ArrayList which adds three objects Loan, Date, Circ...

question_answer

Q: Hi, I am required to: Create an array of 100 integers using a random generator. ( 1 for loop) Provi...

A: create an array which able to store 100 integer numbers.Random class is used for generating 100 inte...