Hi guys sorry I put the whole program in but I felt that it would be hard to see my error if i didn't
I need help on 2 parts of this.
First let me tell you what the program is for and what it is supposed to do.
I need to create a data base program in where a user such as a teacher in this case enters names, ID's and 3 test scores of student by selecting "P" (Populate). For this example I am running the program only for 2 students but I ultimately need to run it for 10.
When the teacher enters "D" (Display Info) it should search for the students ID and bring up the students Name, ID and the 3 test scores.
If "C" (Calculate) is selected the program should find the Students 3 test scores and print out students name and the avg of the 3 scores.
So far it will do all of what I just mentioned once with out a hitch except it runs in to 2 problems
1st problem is if you enter "D" it will do the search as it should but then it gets stuck on the loop till it runs the range number in this case 2 I don't want it to do that it should do the search then go back to the main menu.
2 end problem is when you hit "C" it will give you the avg score but then it looks like it wants to run the range number so it loops, which I don't want it to do it should go back to main menu but when it comes to this line for i in range (len(student_ID[i])):
on it's second time around it comes up as an error don't know why it comes up as an error the second time but not the first?
This is a HW assignment by the way
simple data base program Code:
- simple data base program Code
flt_addscore = 0.0
int_avg = 0
flt_avg = 0.0
#Main menu CMD's
pop = "P"
dinfo = "D"
calG = "C"
exit = "E"
student_name = 
student_ID = 
student_score1 = 
student_score2 = 
student_score3 = 
#cmd P Main Program
while exit == "E":
str_entcmd = input ("Please enter (P) add student info (D) display student info (C) calculate test scores (E) exit")
for i in range(0,2):
if str_entcmd == pop:
str_name = input ("Enter, Student name")
str_ID = input ("Enter New Sturdent, ID")
str_score1 = input ("Test score 1")
str_score2 = input ("Test score 2")
str_score3 = input ("Test score 3")
int_score1 = float (str_score1)
flt_score1 = int_score1
int_score2 = float (str_score2)
flt_score2 = int_score2
int_score3 = float (str_score3)
flt_score3 = int_score3
elif str_entcmd == calG:
ID_search = input ("Please enter studets ID to display students average test score.")
for i in range (len(student_ID[i])):
if ID_search == student_ID[i]:
int_addscore = float (int_addscore)
flt_addscore = int_addscore
flt_addscore = flt_score1 + flt_score2 + flt_score3
int_avg = float (int_avg)
flt_avg = int_avg
flt_avg = flt_addscore / 3
print (student_name[i]," Test Average Score is", flt_avg)
if str_entcmd == dinfo:
ID_search = input ("Please enter student ID to be searched:")
for i in range(len(student_ID)):
if ID_search == student_ID[i]:
print ("Your search results are:")
print ("Students Name:", student_name[i])
print ("Students ID number is", student_ID[i])
print ("Exam scores are:")
print ("Test score 1:", student_score1[i])
print ("Test Score 2:", student_score2[i])
print ("Test Score 3:", student_score3[i])