Python Forum
help me make this code better please (basic)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help me make this code better please (basic)
#1
It works fine if i give the right numbers LOL
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 Angel

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')
Reply


Messages In This Thread
help me make this code better please (basic) - by bntayfur - Jun-04-2020, 02:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Please help to make the code smaller dexomol 2 3,213 Feb-26-2021, 09:56 PM
Last Post: dexomol

Forum Jump:

User Panel Messages

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