Question

In: Computer Science

by python Question #1 Consider a 5-point quiz system. A score can be any number between...

  • by python

  • Question #1 Consider a 5-point quiz system. A score can be any number between 0 and 5. Using mathematical interval notation, the score is in the interval [0,5][0,5]. The interval notation (4,5](4,5] means that number 4 is not in the interval. Hence the numbers included in this interval are all real values ?x such that 4<?≤54

  • The score is graded according to the following scale:

Score Grade
(4, 5] A
(3, 4] B
(2, 3] C
(1, 2] D
[0, 1] F
  • Write a program that reads a quiz score and then prints out the corresponding grade.

  • Note that your program should

    1. Prompt the user of your program using an appropriate message.
    2. Check that the input is within range (from 0 to 5). If the wrong input is given, the program should ask the user for input again until he enters a valid input.
    3. Print an output message reading: “Your grade is ” followed by the grade.
  • The following are two sample runs of the program:

  • Sample Run 1:
    Please enter score: -1
    Invalid score. Try again.
    Please enter score: 5.5
    Invalid score. Try again.
    Please enter score: 3.5
    Your grade is B

  • Sample Run 2:
    Please enter score: 5
    Your grade is A

Solutions

Expert Solution

#display grades according to your marks
def display_grade():
    #takes input from the user
    grade = input("Please enter score: ")
    #1
    if(4<grade<=5):
        print("Your grade is A")
    #2
    elif(3<grade<=4):
        print("Your grade is B")
    #3
    elif(2<grade<=3):
        print("Your grade is C")
    #4
    elif(1<grade<=2):
        print("Your grade is D")
    #5
    elif(0<=grade<=1):
        print("Your grade is F")
    #repeat the function when wrong input is given
    #6
    else:
        print("Invalid score. Try again.")
        display_grade()
    return 0
    

dislpay_grade()


1. if gardes lie between 4 and 5 or equal to 5 then grade will be printed as "A".

2. if gardes lie between 3 and 4 or equal to 4 then grade will be printed as "B".

3. if gardes lie between 2 and 3 or equal to 3 then grade will be printed as "C".

4. if gardes lie between 1 and 2 or equal to 2 then grade will be printed as "D".

5. if gardes lie between 0 and 1 or equal to 0 and 1 then grade will be printed as "F".

6. if any other inputs is given then "Invalid" will be printed and the function repeat itselves.


Related Solutions

There are 25 students in a class. The lowest quiz score is a 5. The average...
There are 25 students in a class. The lowest quiz score is a 5. The average quiz score is 14, median is 15, and SD is 3. If the student who got a 5 has their grade changed to a 10, what happens to the average, the median, and the SD, respectively? Answer in detail.
In Python, write a program that allows the user to enter a number between 1-5 and...
In Python, write a program that allows the user to enter a number between 1-5 and returns the vitamins benefits based on what the user entered. The program should: Continue to run until the user quits and Validate the user’s input (the only acceptable input is 0, 1, 2, 3, 4, or 5), If the user enters zero “0” the program should terminate You can use the following facts: 1- Vitamin A protects eyes from night blindness and age-related decline...
In Python, write a program that allows the user to enter a number between 1-5 and...
In Python, write a program that allows the user to enter a number between 1-5 and returns the vitamins benefits based on what the user entered. The program should: Continue to run until the user quits and Validate the user’s input (the only acceptable input is 0, 1, 2, 3, 4, or 5), If the user enters zero “0” the program should terminate You can use the following facts: 1- Vitamin A protects eyes from night blindness and age-related decline...
Question 1 (1 point) The number of teen pregnancies in the US ______ between the 1990's...
Question 1 (1 point) The number of teen pregnancies in the US ______ between the 1990's and the present. Question 1 options: a) increased by almost 25% b) doubled c) decreased d) stayed about the same Question 2 (1 point) 2 year old Alex shows evidence of learning difficulties, motor delays, and hyperactivity. He also has unusual facial features including small eye openings, a thin upper lip, and a short nose. His mother smoked and drank while she was pregnant...
uestion 5 (1 point) If μ=5.06 and σ=1.27, find the z-score for x=6.87. Question 5 options:...
uestion 5 (1 point) If μ=5.06 and σ=1.27, find the z-score for x=6.87. Question 5 options: 1.43 2.89 -1.43 -2.89 Question 6 (1 point) If μ=63.81 and σ=7.94, find the z-score for x=50.16. Question 6 options: -1.72 -1.719 1.72 1.719 Question 7 (1 point) Use the following set of sample values to answer the question. 33 36 27 30 35 25 19 23 36 10 20 23 13 21 16 37 26 37 12 32 What is the IQR (interquartile...
Python program. Write a python program that can convert any radix-d (arbitrary base) number to the...
Python program. Write a python program that can convert any radix-d (arbitrary base) number to the equivalent radix-e (another arbitrary base) number. Where e and d are members in [2, 16]. Remember, base 16 needs to be calculated as hexadecimal. So, if radix-d is input as a hexadecimal number, it needs to convert and output to desired base. Conversely, if base 16 is the desired output, then the output needs to show a hexadecimal number. Hints: The easiest approach is...
Operating Systems Question 1.What is the maximum number of processes in the system at any time...
Operating Systems Question 1.What is the maximum number of processes in the system at any time using the following code segment? extern char mypath[]; for ( int i = 0; i < 10; i++ ) { pid_t pid, pid_out; unsigned char status; if ( pid = fork() ) pid_out = wait ( &status ); else execl ( mypath, "child", "parameter", NULL ); } Assume that child performs some simple computation and returns the result, that is captured in status.
Quiz Question 1 (1 point) What characteristic of WLAN makes it vulnerable to a different set...
Quiz Question 1 (1 point) What characteristic of WLAN makes it vulnerable to a different set of attacks from wired LANs? Question 1 options: WLAN often is connected to a wired LAN It's difficult to effectively contain the radio signals. WLAN is very difficult to setup and manage None of above Question 2 (1 point) Which of the following can be categorized an integrity attack to a WLAN? Question 2 options: War driving Denial of service 802.11 Frame Injection Radio...
Use Python, please type. A multiple-choice quiz with 5 questions. Each question has 4 possible answers...
Use Python, please type. A multiple-choice quiz with 5 questions. Each question has 4 possible answers labelled A, B, C and D.    After displaying the first question and the 4 possible answers, the user is asked to enter their choice. If their choice is correct, add 1 to the score, then display the next question and its 4 possible answers. At the end of the quiz, display their score out of 5, their score as a percentage, and if...
Question 1 Consider the method displayRowOfCharacters that displays any given character the specified number of times...
Question 1 Consider the method displayRowOfCharacters that displays any given character the specified number of times on one line. For example, the call: displayRowOfCharacters('*', 5); produces the line: ***** Implement this method in Java by using recursion. Question 2 Write a method that asks the user for integer input that is between 1 and 10, inclusive. If the input is out of range, the method should recursively ask the user to enter a new input value. HELP ME PLEASE.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT