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
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.
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.
Write a Python program to prompt for a score between 0.0 and 1.0. If the score...
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)
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."
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...
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.
[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 program(Python language for the following three questions), with comments, to do the following: Ask the user to enter an alphabetic string and assign the input to a variable str1. Print str1. Check if str1 is valid, i.e. consists of only alphabetic characters. If str1 is valid Print “<str1> is a valid string.” If the first character of str1 is uppercase, print the entire string in uppercase, with a suitable message. If the first character of str1 is...
PYTHON CODING Create a program that prompts the user twice. The first prompt should ask for the user's most challenging course at Wilmington University. The second prompt should ask for the user's second most challenging course. The red boxes indicate the input from the user. Your program should respond with two copies of an enthusiastic comment about both courses. Be sure to include the input provided by the user to display the message. There are many ways to display a...
Write this program using python. In your program, when you prompt users for values, only prompt them to enter one value at a time. Here is a sample of what your program should look like. Sample Program Run (User input in bold) What is the length of the room (in feet)? 50 What is the width of the room (in feet)? 30 What is the length of the table (in feet)? 8 What is the width of the table (in...
This is in C++. Example: You will write a program that will prompt the user to enter a grade out of 100 and then show them what the equivalent grade points value is. The main() function will handle the input and output tasks, but the actual conversion will occur in a function called GradePoints(). GradePoints Specifications This function is strictly a processing function, meaning that there are no console input or output steps in the actual function. Consider that this...
Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...