Chat with us, powered by LiveChat Computegrade In PYTHON | Wridemy

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

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Wridemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order

Related Tags

Academic APA Writing College Course Discussion Management English Finance General Graduate History Information Justify Literature MLA