Computegrade in python | Computer Science homework help

[ad_1]

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

 

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with Australia Assessments
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Business and administrative studies
The grade was 100%- Oh man I will be back again. Thank you.
Customer 463293, April 27th, 2023
SEO
good job
Customer 463813, April 11th, 2023
Sociology
Always confirm page length (word count) before submitting.
Customer 462809, April 6th, 2022
Accounting
the first time around paper was very poor and plagiarized according to grammaly with the help of online support it was reassigned and improved greatly
Customer 453819, February 20th, 2020
Education
You see, you can write quality papers. Just practice conciseness.
Customer 462495, April 9th, 2022
Leadership Studies
Excellent job.
Customer 456821, April 21st, 2022
Accounting & Finance
good work
Customer 452441, April 12th, 2022
Other
Check the APA cover page sample on this student paper https://owl.purdue.edu/owl/research_and_citation/apa_style/apa_formatting_and_style_guide/apa_sample_paper.html
Customer 462457, March 29th, 2022
Psychology
This well done
Customer 452763, November 26th, 2021
Other
Good follow-up task.
Customer 459155, April 7th, 2022
Military
Good job
Customer 456821, November 28th, 2022
Business and administrative studies
As I expected.
Customer 460551, December 15th, 2021
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat