943,526 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 440
  • Python RSS
Jun 25th, 2009
0

urgent help

Expand Post »
python Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Jintu is offline Offline
38 posts
since Jun 2009
Jun 25th, 2009
1

Re: urgent help

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.
Reputation Points: 186
Solved Threads: 77
Posting Pro in Training
shadwickman is offline Offline
495 posts
since Jul 2007
Jun 25th, 2009
0

Re: urgent help

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!
Reputation Points: 546
Solved Threads: 99
Practically a Posting Shark
wildgoose is offline Offline
891 posts
since Jun 2009
Jun 26th, 2009
1

Re: urgent help

Click to Expand / Collapse  Quote originally posted by wildgoose ...
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.
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Cheat card game python project
Next Thread in Python Forum Timeline: easy homework help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC