Jun-04-2020, 02:55 AM
It works fine if i give the right numbers
All the input must be between 0 and 100, it doesn't check that.
How do i make the code simpler? For example, in if elif else part is there a way to just give range? I tried to do it but i couldn't.
Help me improve this code pls

All the input must be between 0 and 100, it doesn't check that.
How do i make the code simpler? For example, in if elif else part is there a way to just give range? I tried to do it but i couldn't.
Help me improve this code pls

midterm_1=input('Please enter your first midterm score: ') midterm_2=input('Please enter your second midterm score: ' ) midterm_total= float(midterm_1)*(20/100) + float(midterm_2) * (20/100) print('your total percentage from midterm scores is: ' + str(midterm_total)) summary_paper=input('Please enter your summary paper score: ') summary_total= float(summary_paper) * (10/100) print('your total percentage from summary paper is: ' + str(summary_total)) response_paper=input('Please enter your response paper score: ') response_total= float(response_paper) * (20/100) print('your total percentage from response paper is: ' + str(response_total)) i=1 my_list = [] while i <=10: try: my_list.append(int(input('please enter your discussions scores: '))) i += 1 except: print('you made an error,please try again') print(my_list) l=[] for x in my_list: dis_score = x * (2/100) l.append(dis_score) print('your total percentage from discussion scores is: '+ str(sum(l))) k=1 my_list2 = [] while k <= 5: try: my_list2.append(int(input('please enter your top hat scores: '))) k += 1 except: print('you made an error,please try again') print(my_list2) s=[] for x in my_list2: tophat_score = x * (2/100) s.append(tophat_score) print('your total percentage from discussion scores is: '+ str(sum(s))) total_sum = midterm_total + summary_total + response_total + sum(l)+ sum(s) if total_sum >= 86: print('You received an A with total score of ' +str(total_sum)) elif total_sum>=74 and total_sum<=85 : print('You received a B with total score of ' +str(total_sum)) elif total_sum >=62 and total_sum<=73: print('You received an C with total score of ' +str(total_sum)) elif total_sum >=54 and total_sum <=61: print('You received an D with total score of ' +str(total_sum)) else: print('you failed the course')