urgent help

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jun 2009
Posts: 38
Reputation: Jintu is an unknown quantity at this point 
Solved Threads: 0
Jintu Jintu is offline Offline
Light Poster

urgent help

 
0
  #1
Jun 25th, 2009
  1. total = 0
  2. max_score = -1
  3. min_score = 100000000
  4. total_numbers = 0
  5. x = 0
  6. y = 0
  7. print("Enter a list of numbers, (Enter -1 to stop) ")
  8. print ("Press the enter key after entering each number")
  9. print ("End the list by entering -1")
  10. print ()
  11. number = int(input(""))
  12. while number != -1:
  13. total = total + number
  14. if number > max_score:
  15. max_score = number
  16. if number < min_score:
  17. min_score = number
  18. total_numbers = total_numbers + 1
  19. average = total / total_numbers
  20. if x < average:
  21. x = x + 1
  22. if number <= 50:
  23. y = y + 1
  24. number = int(input(""))
  25. continue
  26. print ()
  27. print ("You have entered " + str(total_numbers) + " scores ")
  28. print ()
  29. print ("The top score is " + str(max_score))
  30. print ()
  31. print ("The lowest score is " + str(min_score))
  32. print ()
  33. print ("The class average is %0.3f " % (average))
  34. print ()
  35. print (str(x) + " students scored above the class average ")
  36. print (str(y) + " students passed the final exam ")
  37. while 1:
  38. print ()
  39. if 'y' in input("Do you want to run the program again? (y/n) "):
  40. pass
  41. else:
  42. print ()
  43. print ('Thank you for using this program!')
  44. print ()
  45. print ('Goodbye!')
  46. break
  47. print("Enter a list of numbers, (Enter -1 to stop) ")
  48. print ("Press the enter key after entering each number")
  49. print ("Signal the end of the list by entering -1")
  50. print ()
  51. number = int(input(""))
  52. max_score = -1
  53. min_score = 100000000
  54. total = 0
  55. total_numbers = 0
  56. x = 0
  57. y = 0
  58. while number != -1:
  59. total = total + number
  60. if number > max_score:
  61. max_score = number
  62. if number < min_score:
  63. min_score = number
  64. total_numbers = total_numbers + 1
  65. average = total / total_numbers
  66. if x < average:
  67. x = x + 1
  68. if number <= 50:
  69. y = y + 1
  70. number = int(input(""))
  71. continue
  72. print ()
  73. print ("You have entered " + str(total_numbers) + " scores ")
  74. print ()
  75. print ("The top score is " + str(max_score))
  76. print ()
  77. print ("The lowest score is " + str(min_score))
  78. print ()
  79. print ("The class average is %0.3f " % (average))
  80. print (str(x) + " students scored above the class average ")
  81. print (str(y) + " students passed the final exam ")

how many people scored above average - how do i find this?
how many people passed the course (i.e. scored >= 50) - how do i find this?

Please help, thanks

Tony
Last edited by vegaseat; Jun 26th, 2009 at 10:04 pm. Reason: added code tags
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 489
Reputation: shadwickman will become famous soon enough shadwickman will become famous soon enough 
Solved Threads: 76
shadwickman's Avatar
shadwickman shadwickman is offline Offline
Posting Pro in Training

Re: urgent help

 
1
  #2
Jun 25th, 2009
PLEASE! Use [code=python][/code] tags! If you look at your post, you realize your Python code has no indentation anymore, and indentation is a crucial part of Python. I'm not going to bother looking through your code until you edit that post and put your code in those tags to preserve the spacing.
"Two good old boys in a fire-apple red convertible. Stoned. Ripped. Twisted. Good people."
- Hunter S. Thompson

my photography
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: urgent help

 
0
  #3
Jun 25th, 2009
Are you using a 32-bit compiler or a 16-bit?
If 16-bit then you have a problem!


100000000
is 05f5e100 in hex requiring 32-bits to store. Since you are being signed due to the -1, It seems a Highes score of 32767 would be a more suitable test, IFF you are using a 16-bit compiler!
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,135
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 946
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: urgent help

 
1
  #4
Jun 26th, 2009
Originally Posted by wildgoose View Post
Are you using a 32-bit compiler or a 16-bit?
If 16-bit then you have a problem!


100000000
is 05f5e100 in hex requiring 32-bits to store. Since you are being signed due to the -1, It seems a Highes score of 32767 would be a more suitable test, IFF you are using a 16-bit compiler!
This is Python, the interpreter handles very large integer values only limited by available memory.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum


Views: 269 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC