Issues with Loops and Conditional Statements in Python 3 -
Issues with Loops and Conditional Statements in Python 3 -
this question has reply here:
how test 1 variable against multiple values? 13 answersi origin programmer, , trying create grade book programme professor @ university, may input midterm , final exam scores , average , letter grade each pupil per course. programme supposed input course of study number, course of study level, number of exams, , pupil info (id , exam scores).
at first thinking create dictionary id key , average value, didn't seem work, started seek , create while loops conditional.
basically code mess, , not sure doing wrong. have watched tutorials , read ton of things online, i'm hitting brick wall this. 1 thing maintain getting invalid syntax error on line 22 elif statement. help can give appreciated! apologies in advance leaving out here - new this.
thank you!
print("hello! welcome grading program!\n") coursecode = input("please come in course of study code : ") courselevel = input("please come in course of study level : ") numberexams = float(input("please come in number of exams : ")) enterstudents = input("would input student, yes or no? : ") pupil = 0 while enterstudents == "yes" or "yes" or "y" or "y" : if courselevel == "undergrad" or "undergrad" or "undergraduate" or "u" or "u": pupil in range(int(numberexams)): id = input("please come in pupil id: ") midterm = int(float(input("please come in midterm score: "))) finalexam = int(float(input("please come in final exam score: "))) undaverage = (midterm * .60) + (finalexam * .40) elif courselevel == "grad" or "grad" or "graduate" or "g" or "g": pupil in range(int(numberexams)): id = input("please come in pupil id: ") midterm = int(float(input("please come in midterm score: "))) finalexam = int(float(input("please come in final exam score: "))) undaverage = (midterm * .30) + (finalexam * .70) elif enterstudents == "no" or "no" or "n" or "n" : print("\nsee next time!") else: enterstudents == "" : input("invalid entry! input student, yes or no?:") def grade(): letter in grade: total = 100 letter in grade(a,b,c,d,e,f): if undgrade == "a": undaverage >= range(85,101) elif undgrade == "b": undaverage >= range(70,85) elif undgrade == "c": undaverage >= range(55,70) elif undgrade == "d": undaverage >= range(40,55) elif undgrade == "f": undaverage >= range(0,40) print(grade)
your or
statements should 'complete'.
elif courselevel == "grad" or "grad" or "graduate" or "g" or "g":
needs become:
elif courselevel == "grad" or courselevel == "grad" or courselevel == "graduate" or courselevel == "g" or courselevel == "g":
easier like:
elif courselevel.lower() in ['grad', 'graduate', 'g']:
.lower():
cater ignore case sensitive words
in []:
item in list/array
furthermore (credits @ashwini), while-elif
combination not exist.
python loops python-3.x while-loop conditional-statements
Comments
Post a Comment