#funtions being defined def add(x,y): return x + y def divide(x,y): return x / y def average(x,y): return (x + y) / len(num_assignments) def multiply(x,y): return x * y #Add the nth value to the value of the numeric value def ordinal(n): return "%d%s" % (n,"tsnrhtdd"[(n//10%10!=1)*(n%10<4)*n%10::4]) #variables list html_link = 'https://upchieve.org/students/' num_assignments = float(input('How many assignments have been completed in the class so far?')) assignment_grades = [] assignment_totals = [] # 1st Loop for i in range(0,int(num_assignments),1): grade = float(input(f'Enter The grade received on the {ordinal(i + 1)} assignment:')) total = float(input(f'Enter the total points possible for the {ordinal(i + 1)} assignment:')) assignment_grades.append(grade) assignment_totals.append(total) assignment_totals_received = sum(assignment_grades) assignment_totals_possible = sum(assignment_totals) assignment_average = divide(assignment_totals_received, num_assignments) assignment_total_average = divide(assignment_totals_possible, num_assignments) assignment_start_percent = divide(assignment_totals_received, assignment_totals_possible) assignment_percent = multiply(assignment_start_percent, 100) #print statement print('You have completed {:.0f} so far in this course.'.format(num_assignments)) print('The average for the {:.0f} assignments is {:.0f} points, out of an average total of {:.0f} points.'.format(num_assignments, assignment_average, assignment_total_average)) print('The total points received on the {:.0f} assignments is {:.0f} points, out of the {:.0f} points possible.'.format(num_assignments, assignment_totals_received, assignment_totals_possible)) #if-else statement with print() parameter if assignment_percent >= 90: print('You passed with flying colors obtaining a {:.0f}%. Keep up the good work.'.format(assignment_percent)) elif assignment_percent < 90 and assignment_percent >= 80: print('You did really good, getting an {:.0f}%. If you wish to make an A, check out this site in your free time: {}'.format(assignment_percent, html_link)) elif assignment_percent < 80 and assignment_percent >= 70: print('You did better than some, but some did better than you. You got a {:.0f}%. Perhaps you should make some time to go to: {} '.format(assignment_percent, html_link)) elif assignment_percent < 70 and assignment_percent >=60: print('You did pass the assignments, but you could have done better. You got a {:.0f}%. You should probably visit {}.'.format(assignment_percent, html_link)) else: print('You obtained only {:.0f}%. A tutor could be helpful for your future assignments. Here is a website for you to consider: {}'.format(assignment_percent, html_link))
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter