Question

In: Computer Science

USING PYTHON ONLY Write a gradebook program that lets a teacher keep track of test averages...

USING PYTHON ONLY

Write a gradebook program that lets a teacher keep track of test averages for his or her students. Your program should begin by asking the teacher for a number of students in their class as well as the total # of tests that will be given to the class. Validate this information to ensure that the numbers entered are positive.

Next, prompt the teacher to enter in scores for each student. Ensure that the values entered are positive - if they aren't you will need to re-prompt them. Hint: you may need to use nested loops here! A "while" loop can be placed inside of a "for" loop, if necessary.

Once your program has collected all test scores for a student it should display that student's average and move onto the next student. When all students have been calculated the program should compute the overall average score for the entire class.

Here's a sample running of your program:

How many students are in your class? -5
Invalid # of students, try again.

How many students are in your class? 3
How many tests in this class? -10
Invalid # of tests, try again.
How many tests in this class? 2

Here we go!

**** Student #1****
Enter score for test #1: -50
Invalid score, try again
Enter score for test #1: 50
Enter score for test #2: 75
Average score for student #1 is 62.50

**** Student #2****
Enter score for test #1: 100
Enter score for test #2: 90
Average score for student #2 is 95.00

**** Student #3****
Enter score for test #1: -10
Invalid score, try again
Enter score for test #1: -20
Invalid score, try again
Enter score for test #1: -30
Invalid score, try again
Enter score for test #1: 90
Enter score for test #2: 80
Average score for student #3 is 85.00

Average score for all students is: 80.83

Some hints:

  • Begin by constructing a "for" loop to iterate over all students in the class
  • Once you're inside of this "for" loop you will probably need another loop to handle inputting the scores for a particular student.
  • Big hint: Try to get your program to work first without any data validation. You can add this in later once you figure out the general structure of the program.
  • Remember the difference between "for" and "while" loops! "for" loops are used when you want to iterate over a know # of items, and "while" loops can be used to keep the user "caught" indefinately until they fulfill a particular condition. You will probably need to use a combination of these loops to solve this problem.

Solutions

Expert Solution

Python program code along with URL link of program and output screen as similar expected result are given below:

You can see the python code below or You may copy and paste the given URL link in your web browser .

URL link of program: https://repl.it/repls/TenseOrnateScan#main.py

Python code:

# Taking input from user for number of students
n = int(input("Enter the number of students in a class: "))

# Creating list for storing average values
li1 = []

# Condition for invalid entry
if(n<0):
  while(n<0):
    n1 = int(input("Invalid # of students, try again.\n\nHow many students are in your class? "))
    n = n1

t = int(input("How many tests in this class? "))

# Condition for invalid entry
if(t<0):
  while(t<0):
    t1 = int(input("Invalid # of tests, try again.\nHow many tests in this class? "))
    t = t1

print("\nHere we go!\n")
for i in range(1,n+1):
  li = []
  x = 0.0
  print("****Student #",i,"****")
  for j in range(1,t+1):
    print("Enter the score of test #",j)
    z = int(input())

    # Condition for invalid entry
    if(z<0):
      while(z<0):
        z1 = int(input("Invalid score, try again for same test "))
        z = z1
    li.append(z)
  
  # Applying formula for average
  x = sum(li)/len(li)

  # Finding average of students
  print("Average score for student #",i," is ",x)
  print("\n")
  li1.append(x)

y = 0.0

# Applying formula for average
y = sum(li1)/len(li1)

# Giving output as average of all students
print("Average score for all students is: ",y)

Output screen:

Thank you!!! Good luck! keep coding :)


Related Solutions

Write a Java program that lets the user keep track of their homemade salsa sales. Use...
Write a Java program that lets the user keep track of their homemade salsa sales. Use 5-element arrays to track the following. The salsa names mild, medium, sweet, hot, and zesty. The number of each type sold. The price of each type of salsa. Show gross amount of money made (before tax). Calculate how much the user owes in sales tax (6% of the amount made). Then display the net profit (after subtracting the tax).
Write a c++ program for the Sales Department to keep track of the monthly sales of...
Write a c++ program for the Sales Department to keep track of the monthly sales of its salespersons. The program shall perform the following tasks: Create a base class “Employees” with a protected variable “phone_no” Create a derived class “Sales” from the base class “Employees” with two public variables “emp_no” and “emp_name” Create a second level of derived class “Salesperson” from the derived class “Sales” with two public variables “location” and “monthly_sales” Create a function “employee_details” under the class “Salesperson”...
ASSIGNMENT: Write a program to keep track of the total number of bugs collected in a...
ASSIGNMENT: Write a program to keep track of the total number of bugs collected in a 7 day period. Ask the user for the number of bugs collected on each day, and using an accumulator, keep a running total of the number of bugs collected. Display the total number of bugs collected, the count of the number of days, and the average number of bugs collected every day. Create a constant for the number of days the bugs are being...
USE PYTHON-LIST Q1 - You need to keep track of book titles. Write code using function(s)...
USE PYTHON-LIST Q1 - You need to keep track of book titles. Write code using function(s) that will allow the user to do the following. 1. Add book titles to the list. 2. Delete book titles anywhere in the list by value. 3. Delete a book by position. Note: if you wish to display the booklist as a vertical number booklist , that is ok (that is also a hint) 4. Insert book titles anywhere in the list. 5. Clear...
You will design a program to keep track of a restaurants waitlist using a queue implemented...
You will design a program to keep track of a restaurants waitlist using a queue implemented with a linked list. Make sure to read pages 1215-1217 and 1227-1251 1. Create a class named waitList that can store a name and number of guests. Use constructors to automatically initialize the member variables. 2. Add the following operations to your program: a. Return the first person in the queue b. Return the last person in the queue c. Add a person to...
Step by step in python Write a program that will keep asking for a user input...
Step by step in python Write a program that will keep asking for a user input (until a blank line is entered) and will inform me whether what I entered was a valid number or not (without crashing). The program should use at least one try/except loop The program should include at least two custom written functions (a main() function can count as one of the two)
(using for loop, parameters, if, else condition only )Python: Write a program that prompts the user...
(using for loop, parameters, if, else condition only )Python: Write a program that prompts the user to enter a positive integer value, and compute the following sequence: • If the value is even, halve it. • If it's odd, multiply by 3 and add 1. • Repeat this process until the value is 1, printing out each value. • Then print out how many of these operations you performed. If the input value is less than 1, print a message...
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
Write an assembly program that lets the user to input only the word MASM and displays...
Write an assembly program that lets the user to input only the word MASM and displays invalid input for any other user inputs.
This is python: #Imagine you're writing a program to calculate the class #average from a gradebook....
This is python: #Imagine you're writing a program to calculate the class #average from a gradebook. The gradebook is a list of #instances of the Student object. # #You don't know everything that's inside the Student object, #but you know that it has a method called get_grade(). #get_grade() will return the average for the student #represented by a given instance of Student. # #You don't know if get_grade() is stored in memory or if #it's calculated when it's needed, but...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT