Question

Write a Python program to prompt for a score between 0.0 and 1.0. If the score...

  1. Write a Python program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error message. If the score is between 0.0 and 1.0, print a grade using the following table:

    Score Grade >= 0.9 A
    >= 0.8 B
    >= 0.7 C

    >= 0.6 D

    < 0.6 F
    Run the program repeatedly as shown above to test different values for input. Here’s some sample input and output:

    Enter score: 0.95 A

         Enter score: perfect
         Bad score
    

    Enter score: 10.0 Bad score

    Enter score: 0.75 C

    Enter score: 0.5 F

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot of code:

output:

code:

n=int(input("Enter number of times to test: "))
for i in range(0,n):
x=input("Enter score: ")
if x>='0.0' and x<='1.0':
x=float(x)
if x<0.1 or x>1.0:
print("Bad score")
elif x>=0.9:
print('A')
elif x>=0.8:
print('B')
elif x>=0.7:
print('C')
elif x>=0.6:
print('D')
elif x<0.6:
print('F')
else:
print("Bad score")

#please upvote if this answer was helpful.

Add a comment
Answer #2

You can use the following Python program to achieve the desired functionality:

pythonCopy codedef get_grade(score):    if score >= 0.9:        return 'A'
    elif score >= 0.8:        return 'B'
    elif score >= 0.7:        return 'C'
    elif score >= 0.6:        return 'D'
    else:        return 'F'while True:    try:
        score = float(input("Enter score: "))        if 0.0 <= score <= 1.0:
            grade = get_grade(score)            print(f"Grade: {grade}")        else:            print("Bad score. Score must be between 0.0 and 1.0.")    except ValueError:        print("Invalid input. Please enter a numeric score.")

This program defines a function get_grade(score) to determine the grade based on the input score. The program then enters an infinite loop and repeatedly prompts the user for a score. If the input score is valid (between 0.0 and 1.0), it calculates the grade using the get_grade() function and prints it. If the input score is out of range or not a valid numeric value, appropriate error messages are displayed.

You can run the program, and it will continuously prompt for scores and display the corresponding grades until you terminate it manually. Try different input values to see the results.


answered by: mervetokaz
Add a comment
Know the answer?
Add Answer to:
Write a Python program to prompt for a score between 0.0 and 1.0. If the score...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use the graph to estimate K. 1.0 0.75 Yo₂ 0.5 0.25 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 [L] (M)

    Use the graph to estimate K. 1.0 0.75 Yo₂ 0.5 0.25 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 [L] (M)

  • In python, write the contents of the x and y lists to a file called xy2.dat...

    In python, write the contents of the x and y lists to a file called xy2.dat with one value from x and y on each line, separated by a comma. x = [-1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.30000000000000004, -0.19999999999999996, -0.09999999999999998, 0.0, 0.10000000000000009, 0.19999999999999996, 0.30000000000000004, 0.3999999999999999, 0.5, 0.6000000000000001, 0.7, 0.8, 0.8999999999999999, 1.0] y = [1.0, 0.78, 0.67, 0.51, 0.27, 0.0, 0.14, 0.19, -0.14, 0.03, 0.03, -0.09, -0.03, -0.12, 0.14, 0.36, 0.57, 0.63, 0.61, 0.59, 1.01]

  • python - Write a program that converts square feet to square yards. Prompt the user to...

    python - Write a program that converts square feet to square yards. Prompt the user to enter a value in square feet and then print the converted output along with a message similar to "1 sq. ft. is .11111 sq. yards."

  • Write a PYTHON program that reads a file (prompt user for the input file name) containing...

    Write a PYTHON program that reads a file (prompt user for the input file name) containing two columns of floating-point numbers (Use split). Print the average of each column. Use the following data forthe input file: 1   0.5 2   0.5 3   0.5 4   0.5 The output should be:    The averages are 2.50 and 0.5. a)   Your code with comments b)   A screenshot of the execution Version 3.7.2

  • for python-3 I want to prompt the user to enter their first name and then Call...

    for python-3 I want to prompt the user to enter their first name and then Call the is_field_blank function to see if nothing was entered.and If nothing was entered i want it to display the following message "First Name must be Entered" and then re-prompt the user to enter the first name. I want it to do this repeatedly until the user enters a first name. this is what i have so far def main():     yourFirst = input("What is...

  • USE Python 2.7(screen shot code with indentation and output exactly in the question) the task is:...

    USE Python 2.7(screen shot code with indentation and output exactly in the question) the task is: takes in a list of protein sequences as input and finds all the transmembrane domains and returns them in a list for each sequence in the list with given nonpolar regions and returns the lists for those. 1. This code should call two other functions that you write: regionProteinFind takes in a protein sequence and should return a list of 10 amino acid windows,...

  • Write a "PYTHON" program to prompt the user to enter a fist name, last name, student...

    Write a "PYTHON" program to prompt the user to enter a fist name, last name, student ID and GPA. Create a dictionary with the data. Print out the data. Then remove the GPA and print again.

  • Evaluate the integral for values of x from 0 to 3 in steps of 0.1 AND plot the integral. The prog...

    Evaluate the integral for values of x from 0 to 3 in steps of 0.1 AND plot the integral. The program needs to be written in Python 3. Can only import numpy and matplotlib. CAN NOT use lambda functions or classes of any kind. Exercise 5.3: Consider the integral Plot of the integral from 0 to x 0.8 e: more hints You need to print E(x) with different x values. 0.6 1 Plotting the function will help The calculated values...

  • [Using Python] Use the grade scale in the syllabus for this class, write a program that...

    [Using Python] Use the grade scale in the syllabus for this class, write a program that inputs a score, and prints the grade for that score. For example, if I input 90.0, your program should print A. Grading Scale is: 100% - 90% A 89% - 80% B 79% - 70% C 69% - 60% D 59% - 0% E

  • Write a small c++ program, that does the following Prompts user to input a score between...

    Write a small c++ program, that does the following Prompts user to input a score between 1-10 (assume the user will honor the request) Stores the user input in an appropriate variable (appropriate in type and name) Checks if the score is a passing grade. Assume 70% or more is needed Displays a message only if the score is passing.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT