Python Forum
Problem with a homework
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with a homework
#1
Hello,

I am trying to create a program which reads a number N>=2 and creates a list. Then it fills the list with numbers and finds the average of them. Finally, it finds the amount of numbers which are greater than the average and it shows the percentage of them. There is a problem in my code, but I can't understand what it is. The problem is that it doesn't run at all. I believe it is probably a syntax error or something, but I don't know what. I use Python 3.6.4 at Windows 10 if that helps. I am a beginner at coding and python, so please be gentle.

Thank you in advance

Here is my code:

A=[]
average=0
max=0

N=int(input("Give the number of data of the list\n\n")
if (N<2):
    print ("The number you gave is wrong\n\n")
    while (N<2):
        N=int(input("Give the number of data of the list again\n\n")

print ("Give the numbers of the list\n\n")
for i in range(1,N):
    A[i]=int input
    average=average+A[i]

average=average/N
print ("The average is", average)

for i in range (1,N):
    if (A[i]>average):
        max++

num=100/N
max=max*num
print("The percentage of the data which are grater than the average is %s%", max
Reply


Messages In This Thread
Problem with a homework - by Samuelcu - Feb-03-2018, 10:12 AM
RE: Problem with a homework - by metulburr - Feb-03-2018, 01:25 PM
RE: Problem with a homework - by Samuelcu - Feb-03-2018, 01:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with a formula 1 kind of homework claroque 2 1,449 Jun-20-2023, 09:58 PM
Last Post: claroque
  Bakery Problem.. Can you Help My Homework Cemvrs 1 2,394 Jan-14-2022, 05:47 PM
Last Post: Yoriz
  Need help with a homework problem on logical operators voodoo 3 4,615 Jun-28-2019, 03:45 PM
Last Post: jefsummers
  Homework Problem csascott 1 2,296 Oct-27-2018, 04:44 AM
Last Post: scidam
  Homework Problem Travisbulls34 1 2,970 Sep-11-2018, 04:04 PM
Last Post: ichabod801
  Help with homework problem - iterating a function midnitetots12 4 3,537 Feb-21-2018, 10:51 PM
Last Post: nilamo
  Homework problem Dem_Prorammer 1 3,819 May-20-2017, 07:49 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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