1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
anygoal [31]
3 years ago
11

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

a credit. For the given program, sum_extra is 8 because 1 + 0 + 7 + 0 is 8. Sample output for the given program:
test_grades = [101, 83, 107, 90]
sum_extra = -999 # Initialize 0 before your loop
sum_extra = 0
for grade in test_grades:
if grade > 100:
grade = grade - 100
else:
grade = 0
sum_extra += grade

print('Sum extra:', sum_extra)

Computers and Technology
1 answer:
Kay [80]3 years ago
3 0

Answer:

Complete python code with explanation and output results is given below.

Explanation:

We have a list of grades test_grades and some of those grades have received extra credit and therefore, their grade is greater than 100.

Now we have to sum all these extra credit from each grade that is greater than 100

Please note that I have created another test_grades2 list to verify and be sure whether program is showing correct results or not.

Python Code:

# lists of grades

test_grades = [101, 83, 107, 90]

test_grades2 = [105, 108, 103, 90, 104, 78]

# to do the sum we have used the sum() function and a for loop runs through entire list to check the condition grade>100 if condition is true then minus 100 from it and keep adding it in the sum_extra.

sum_extra = sum([grade - 100 for grade in test_grades if grade > 100])

sum_extra2 = sum([grade2 - 100 for grade2 in test_grades2 if grade2 > 100])

# then finally print the sum_extra

print('Sum extra: '+str(sum_extra)+' for test_grades')

print('Sum extra: '+str(sum_extra2)+' for test_grades2')

Output:

Sum extra: 8 for test_grades

Sum extra: 20 for test_grades2

The results are correct and the program is working correctly as it was required.

Note: feel free to ask in the comment if you don't understand anything

You might be interested in
You are driving on expressway with three lanes in your direction at a speed lower then
Kaylis [27]

<em>ANSWER:</em>

<em></em>

<h2>Pass on the left<em> </em></h2>

6 0
4 years ago
Read 2 more answers
The command to delete all the files that have filenames that starts with letter c or c and ends with a letter z or z is
dimaraw [331]
The command is : <span>rm [Aa]*[Zz] </span>
4 0
3 years ago
All of the language commands that the CPU understand make up the CPU's
disa [49]
I think assembly level command mov ,push ,call
5 0
4 years ago
A bubble starts by comparing the first item in the list to all the remaining items, and swaps where the first item is ____ a lat
Alina [70]

Answer:

greater than

i think

5 0
3 years ago
Read 2 more answers
Which type of network is the internet? choose the answer
Alex Ar [27]

Answer:

WAN or wide area network

Explanation:

The Internet is the most basic example of a WAN. It is connecting all computers together around the world.

5 0
3 years ago
Other questions:
  • A geologist is part of what career feild
    6·1 answer
  • Which of the following functions and expressions will convert the ASCII character "Z" to its numeric equivalent ASCII code?
    7·1 answer
  • Assume that the following code exists inside a method of MyClass, and that this code compiles without errors: int result = book.
    13·1 answer
  • Sofia is reading a difficult text for class and worries that she won't complete it by the given deadline. How can a text-
    13·2 answers
  • Chevening is looking for individuals with strong professional relationship building skills, who will engage with the Chevening c
    15·1 answer
  • What is a well-planned strategy that ensures the search and navigation functions are easy to use and user-friendly on a website?
    15·1 answer
  • Complete the method, print Multiples(), that takes in a positive integer n, and another positive integer, max. Print out all the
    15·1 answer
  • What is processing requirement in computer?
    11·1 answer
  • How many bits would be needed to count all of the students in class today?There are 25 in class
    15·2 answers
  • What two windows security updates do most organizations always patch?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!