Python Forum
I keep getting errors and I'm lost!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I keep getting errors and I'm lost!
#7
You're getting closer. The code is steadily improving. Here are the most pressing, current issues to address:

1. As written, your code will continue the loop if a non-numeric entry has been entered. Continuing skips the rest of the loop body and starts the next iteration of the loop. If you enter "Quit", it will raise an exception, print "Bad Score", and start over without checking the conditional on line 17. To fix this, you can simply move that conditional into the except block of your try...except.

2. Computegrade() isn't doing anything right now. Your loop is currently infinite because of problem #1 and the interpreter is never executing line 68. Once #1 is corrected, you will receive a new error. What Ichabod was stating earlier relates to the Single Responsibility Principal (SRP; or atomicity). A function should do only one thing. Since computegrade() is all about determining the letter grade of a giving decimal, your entire if statement from lines 30 through 59 should be inside of it (remember to update the keywords when you move it all).

3. Line 68 should be inside the loop. Repeating that line will perform all the calculations for the grade because it's calling computegrade() (once #2 is corrected). Once this is corrected, you'll start seeing the letter grade print twice. This will be due to the print() calls inside of computegrade(), which you don't need.
Reply


Messages In This Thread
RE: I keep getting errors and I'm lost! - by stullis - Oct-27-2018, 10:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I am completely lost on this homework assignment a36 1 1,841 Feb-21-2022, 06:01 AM
Last Post: buran
  Very Lost vollynez 3 1,953 Oct-02-2020, 09:09 PM
Last Post: Yoriz
  I got lost in the program Gadev 1 1,934 Nov-11-2018, 05:50 PM
Last Post: j.crater
  test..and I'm already lost sannixinc 1 2,572 Feb-22-2018, 09:09 PM
Last Post: glidecode
  Completly lost about to fail my class! crakacheezy 7 4,718 Dec-28-2017, 11:50 PM
Last Post: mepyyeti

Forum Jump:

User Panel Messages

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