Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with homework
#1
hey guys, needing some help here! I need to make a program that is going to take a range of numbers which are to be temperatures and store them in a list, it then needs to find the percentage of the numbers in the list that are above 16 can anyone help with this at all? i have put the code below but I cannot for the life of me seem to get it going, im rubbish at programming, I have the bit where it prompts the user for the temperatures and all the temperatures are included that are in the assignment

# work out the percentage of the day that the office was warm enough

#input temperatures of the office on hourly basis
temperatures = [20,15,17,16,14,19,18,19]
for n in range(1, 9):
    temperatures.append(int(input(f'Enter temp {n}: ')))


# find the percentage of the day that the temperature was within acceptable range

# Input a list of 8 numbers
temperatures = [20,15,17,16,14,19,18,19]

#sub-problem: compute the percentage
total = 0
for temperatures in temperatures:
    total = total + temperatures

# sub- problem: compute the length of the list
length = 0
for temperature in temperatures:
    length = length +1

#output: percentage office was warm enough, a number
percentage = total / 100

print('the percentage the office was warm enough', temperatures, 'is', percentage)
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