Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Repition structures?
#1
Hey all, I am trying to finish this code off, but I am stuck with how to add in if the T or S is false and also getting the loop to work properly with the names and grades. Here is what I have so far.
Thank you!

print ("Welcome to Grade Averager. Enter 999 at any time to end this program")
print ()

name = (input ("Please enter a name"))
serviceCode = (input ("Please enter a service code T for teacher or S for student"))
roomnumber = (input ("Please enter a room number"))
assignments = (input ("How many assignments for this class?"))
assignmentgrade = (input ("Enter assignment grade"))

while (assignments <= '2'):
    print ('Please Enter a Name: ') #User inputs either a teacher or students name
    name = (input())
    serviceCode = (input())
    if (serviceCode == "T"):
        print ('Please Enter a Service Code (T or S): ') #User inputs service code; program must accept teacher code first to begin
    elif (serviceCode == "S"):
        print ('Please Enter a Service Code (T or S): ') #User inputs service code; program must accept teacher code first to begin
        serviceCode = (input())
    
    print ('Please Enter a Grade, or Type 999 to Exit.') #User inputs a numerical grade, denoted by the int input
    varGrade = int(input())
    
    if (varGrade != '999'):
        print (varGrade)
        total = "total" + "varGrade"
        print (total)
        count = count + 1
    else:
        break

average = total / count

print ("Average is:" , average)
Output:
EXPECTED OUTPUT EXAMPLE Welcome to Grade Averager. Enter 999 at any time to end this program. Please enter a name: Mr. Jones Please enter a service code: t Please enter a room number: 30 How many assignments for this class? 2 Please enter a name: Bobby Please enter a service code: s Please enter a room number: 30 Enter assignment grade 1: 88 Enter assignment grade 2: 97 Please enter a name: Sue Please enter a service code: s Please enter a room number: 30 Enter assignment grade 1: 72 Enter assignment grade 2: 77 Please enter a name: Jan Please enter a service code: h Sorry, invalid service code. Valid codes are T or S. Please enter a name: Mrs. Johnson Please enter a service code: T Do you want to finalize grades for Mr. Jones, room 30? (Y/N): y Mr. Jones, room 30: Class average is 83.5 Bobby – A Sue — C Please enter a room number: 40 How many assignments for this class? 3 Please enter a name: Patty Please enter a service code: s Please enter a room number: 40 Enter assignment grade 1: 100 Enter assignment grade 2: 100 Enter assignment grade 3: 100 Please enter a name: Marsha Please enter a service code: s Please enter a room number: 40 Enter assignment grade 1: 92 Enter assignment grade 2: 90 Enter assignment grade 3: 100 Please enter a name: 999 Do you want to finalize grades for Mrs. Johnson, room 40? (Y/N): y Mr. Johnson, room 40: Class average is 97 Patty – A Marsha — A Thank you for using Grade Averager.
Reply
#2
What are you trying to do? I don't want to infer this from code because the code is wrong and my understanding will also be wrong. Using your own words, not python code, describe each step of what this program is supposed to do.
Reply
#3
Hi, thank you for looking. I am trying to make it so that when a name is entered, a service code nees to be entered either T or S for teacher or student. The first person entered must be a teacher if not it needs to be instructed that a teacher needs to come first. When someone with a service code of the teacher is entered, the program will ask for a room or class number. This will be used to verify that each of the following students entered are being entered in the correct class. The program will also ask how many assignment grades each student in this class will have. Then the program should accept student names and be followed with a service code of S and the class number is entered and verified. That is when it should loop to request and talls the students grades and then the assignment grades will be averages to find the final average of that students grade.
Upon the entry of a new teacher name and service code the program will display the class number and verify that the user is done entering students for the previous class. If the user says no then the teacher name just entered is discarded. If the user says yes, the program will print the previous teacher and class number followed by the corresponding class list, letter grades and overall class average. Then, using the teacher name just entered, it will request a new class code and start a new class list. For any input, if the service code is not a valid code, the input is discarded and the user must be notified of the valid codes and asked to reenter the data. The user should be able to enter the service code in either lower or upper case.
Whew long winded but I think I covered it all. Thank you!
Reply
#4
That does not tell me what the program is supposed to do. That tells me how I will interact with the program. That is useful information, but what is actually being done while I enter all this information? What does the program do with the grades?

There should be a one or two short sentence description of what the program does. Start with that when designing your code. All this stuff about verifying teacher codes and student codes isn't important until your program can do what it is supposed to do. It kind of sounds like the program should allow entering student grades and computing the average. Not sure what it does with the grades or the average. Start by writing a program that does that part.

After you get the grade processing to work, back up one level and do the part about entering the student name and code. Are the grades going to be saved somewhere? Maybe in a dictionary? Again, I don't know because the only thing I know is how to do data entry. Take the program you wrote that allows entering and processing grades and add the student name and code part. Get that to work.

After you get grade entry working you can finally focus on the teacher part. I have no idea why the teacher name is needed, only that you asked me to type in a name. Does the program remember what students are entered for a teacher?

I guess what I am trying to say is start by solving the most important part of the program first, then add functionality in small chunks. Writing this entire program is complicate, but writing something that lets you enter 5 numbers and compute an average is easy. After you are happy with that, entering a student name and code and then calling your grade entering code is easy. After doing that, getting the teacher name and code and adding that to what you have is easy.

Programming is supposed to be easy. And fun.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  self learning itertools for complex structures enrikS 5 3,935 May-18-2018, 05:53 AM
Last Post: enrikS

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020