Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with homework
#3
first you create a list of temperatures:
temperatures = [20,15,17,16,14,19,18,19]

for n in range(1, 9):
    temperatures.append(int(input(f'Enter temp {n}: ')))
and then the next thing you do is overwrite the list (line 12):
temperatures = [20,15,17,16,14,19,18,19]
so now everything that you entered is gone!

next the following code (lines 15 - 17):
total = 0
for temperatures in temperatures:
    total = total + temperatures
can be shortened to:
total = sum(temperatures)
and lines (20 - 22) can be shortened to:
length = len(temperature)
now you need to write code to pull all items above 16
and calculate % on result
Reply


Messages In This Thread
help with homework - by lga13 - Nov-19-2018, 02:01 PM
RE: help with homework - by ichabod801 - Nov-19-2018, 02:30 PM
RE: help with homework - by Larz60+ - Nov-19-2018, 02:31 PM
RE: help with homework - by Larz60+ - Nov-19-2018, 02:32 PM

Forum Jump:

User Panel Messages

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