Categories
Study Questions

computegrade in PYTHON

Rewrite the grade program from the previous chapter using a function called computegrade that takes a score as its parameter and returns a grade as a string.

Score

Grade

> 0.9

A

> 0.8

B

> 0.7

C

> 0.6

D

<= 0.6

F

 

HINT:

1.     Write a custom function with the definition def computegrade(<your score variable>):

2.     The function should compute the grade using the score variable based on the table above. You can use if-elif statements to accomplish this

3.     Ensure your function has a “return” statement to return the computed grade back to the calling program

4.     Once the function is defined, proceed to writing the part of the program that takes in user input for score.

5.     Validate that the score is numeric within a try-except block.

6.     Invoke the above-defined computegrade function with the user-supplied score. Ensure you capture the return value within your program into a variable placeholder, or else use the print statement to print the return value directly

7.     Be sure to comment your program adequately!

8.     Remember your Python code will be graded according to our class Rubric.

9.     Submit your Python code file.  Name it “XXXX-score-function.py” where XXXX is your name. 

10.  Submit also a Word document showing screen shots of the various testing conditions.  Good programmers test all cases, so you should make sure you show tests for each possible grade level (A through F) plus error messages.

 

here is the code I did. run it, it works.

just need to reflect the computegrade and make that work too

 

# Given a given a numerical grade between 0.0 and 1.0

#This program converts the numerical score in letter grade.

 

#Prompt user for score between 0.0 and 1.0

prompt1 = “Please enter a score between 0.0 and 1.0: “

 

#convert input to float, because the input statement accepts user input as a string by default

#Wrap within a try-except code block to exit gracefully as the conversion will fall if the user supplied a non-numeric input!

try:

  score = input (prompt1)

  score = float(score)

 

#Print the result

  if score <=1.0:

   if 0.9 <= score <= 1.0:

      print(“Your grade is an A”)

   elif score >= 0.8:

      print(“Your grade is a B”)

   elif score >= 0.7:

      print(“Your grade is a C”)

   elif score >= 0.6:

      print(“Your grade is a D”)

   elif score <  0.6:

      print(“Your grade is an F”)

 

 

  else:   

   print (“Error, score cannot be greater than 1.0”)

except:

   print (“Error, please enter a number”)

 

 

#End of Script

 

This page is having a slideshow that uses Javascript. Your browser either doesn't support Javascript or you have it turned off. To see this page as it is meant to appear please use a Javascript enabled browser.

Jessy
Jessy
Just a bit off from the syllabus rubric, but I can add to the slides on my own. Thank you anyway.
Alvin
Alvin
To the writer, THANK YOU, a million times over, this is very impressive! Thank you to the support team for making a hiccup not turn into a disaster!
Milly.P
Milly.P
There was consistent communication from the start, and it was obvious the writer thoroughly reviewed the information provided. Thank you.
Ivy.G
Ivy.G
Excellent work all the time! love my writer also. Don't know if I'm supposed to do this but I just need to say this writer does excellent work!
Emily.s
Emily.s
The writer followed my instruction thoroughly and did a great job. The quality of the paper is more than I expected. Thank you.
Justus N
Justus N
You people have been really patient with me as I created mechanical engineering content. It’s not an easy topic to handle, yet I can say that I worked with a skilled specialist. My writer took time to understand my ideas but it was mostly my fault. Just share more details.
Kelly H
Kelly H
When I received a paper revision from my new college professor, I was desperate as I didn’t know what to do. If not for Academized, I would be doomed. They know how to fix things for you and explain what was wrong as they fix it.
Paul D
Paul D
You're the best, I'll be using your services again soon! Thank you Thank you Thank you!
Mark P.
Mark P.
I asked my writer to help me compose a personal essay about charity work that I do at the local church. It is not easy for me to express myself in words, which is why I needed some privacy and a good person who would appreciate my thoughts and ideas.

error: Content is protected !!
Open chat
1
Do You Need Assignment Help? Lets Chat!
StudyPoo Inc.
Get Help Instantly direct from an Expert.

Talk through Live Chat right now!