Adblock breaks this site

Stuck making a program in python..

Discussion in 'Programming General' started by kmjt, Oct 11, 2010.

  1. kmjt

    kmjt -.- The nocturnal life chose me -.-
    Banned

    Joined:
    Aug 21, 2009
    Posts:
    14,450
    Referrals:
    8
    Sythe Gold:
    449
    Stuck making a program in python..

    I didn't know where else to put this since there is no subforum for python..

    So i'm trying to make a program with the goal of computing the average for test marks for a class of students and somehow record what the maximum mark entered was.

    The thing that kind of confuses me is that there is no set number of marks that is going to be entered. As soon as a mark that is not between 0 and 100 is entered the program will stop asking for more marks.. so every time the program is run it could be that someone enters 23 different legitimate marks or 40 legitimate marks for example.

    How do I make it so the program stops asking for marks after a number not between 0 and 100 is entered? This is what I have tried:



    However this doesn't work. All this does is opens up the program and prompts the user to enter a mark. After a mark is entered, it will ask for a mark again, and again, and again, never stopping (even if the mark entered is below 0 or above 100) What did I do wrong? In the program I did while the mark is less than or equal to 100 and greater than or equal to 0 run the main function again. So say if a negative number of a number greater than 100 is entered shouldn't the main function not be run again?


    To go even further.. how would sum up all of the marks entered as a running total as they are entered? The reason being because I will need to know to find out the average at the end.


    And how would I determine what the max mark entered was?


    I've read through my whole book but nothing is in it about this stuff.. help/guidance would be greatly appreciated.
     
  2. Zed'

    Zed' Member

    Joined:
    Oct 4, 2010
    Posts:
    93
    Referrals:
    0
    Sythe Gold:
    0
    Stuck making a program in python..

    I don't know Python and don't know where the method ends, but you are calling the main method after it has run already so it just runs again?
     
  3. plzmike

    plzmike Newcomer

    Joined:
    Nov 13, 2010
    Posts:
    12
    Referrals:
    0
    Sythe Gold:
    0
    Stuck making a program in python..

< Going over to JAVA? | Stuck on a problem. >


 
 
Adblock breaks this site