Skip to main content

Calculating extra credit scores in python

Extra Credit Calculation in Python

Assign sum_extra with the total extra credit received given list test_grades. Full credit is 100, so anything over 100 is extra credit.

Sample output for the given program with input: 101 83 107 90

Sum Extra = 1 + 7 = 8


 user_input= input()
 test_grades= list(map(int, user_input.split()))
 sum_extra = 0
 for i in test_grades:
     if i>100 :
         sum_extra = sum_extra + i-100
 print('Sum extra:',sum_extra)

Hope this is helpful. Write back to me in case you need help with your python task. I generally reply back within 24 hours. You can connect with me on Whatsapp also: +918602715108

Comments

Popular posts from this blog

Create a list from user's input in python

  Write a loop to populate the list user_gusses with a number of guesses. The variable num_guesses is the number of guesses the user will have, which is read first as an integer. Read each guess (an integer) one at a time using int(input()) Sample output with input 3 9 5 2  user_gusses: [9, 5, 2] num_guesses= int(input()) user_guesses= [] #ask user to enter the user_guesses element for i in range(0, num_guesses): x= int(input()) user_guesses.append(x) print('user_guesses:', user_guesses) Hope this is helpful. Write back to me in case you need help with your python task. I generally reply back within 24 hours. You can connect with me on Whatsapp also: +918602715108

Python program to replace words in a sentence

Write a program that replaces words in a sentence. The input begins with word replacement pairs (original and replacement). The next line of input is the sentence where any word on the original list is replaced. Ex: If the input is: automobile car manufacturer maker children kids The automobile manufacturer recommends car seats for children if the automobile doesn't already have one. the output is: The car maker recommends car seats for kids if the car doesn't already have one. You can assume the original words are unique. w = input().split() x = input() for i in range(0, len(w), 2): if w[i] in x: x = x.replace(w[i], w[i+1]) print(x) Hope this is helpful. Write back to me in case you need help with your python task. I generally reply back within 24 hours. You can connect with me on Whatsapp also: +918602715108

Multidimensional list in python print as matrix

 Two Dimensional List in Python  Print the two-dimensional list mult_table by row and column using Nested loops Sample Output with input: 1 2 3, 2 4 6, 3 6 9 1 | 2 | 3 2 | 4 | 6 3 | 6 | 9  user_input = input() lines = user_input.split(',') mult_table = [[int(num) for num in line.split()] for line in lines] for lst in mult_table: for i in range(len(lst)): print(lst[i], end='') if i != len(lst)-1: print(' | ', end='') print() Hope this is helpful. Write back to me in case you need help with your python task. I generally reply back within 24 hours. You can connect with me on Whatsapp also: +918602715108