Question

In: Computer Science

Reading code that you haven't written is a skill you must develop. Many times you are...

Reading code that you haven't written is a skill you must develop. Many times you are correcting this code that you didn't write so you have to 1) read the code, 2) find the errors, and 3) correct them.

# Describe the error found in this function:

def get_grade():

grade = int(input("Enter your test score > ")

# Describe the error found in this function:

def all_As(test1, test2, test3):

if test1 > 89:

if test2 > 89:

if test3 > 89:

print("Wow! ", end="")

print("You scored 90 or above on all your exams!")

print("Keep up the As!")

print()

# Describe the error found in this function:

def calc_average(test1, test2, test3):

average = test1 + test2 + test3 / 3

return average

# Describe the error found in this function:

def letter_grade(grade):

if grade >= 90:

print("You earned an A")

if grade >= 80:

print("You earned an B")

if grade >= 70:

print("You earned an C")

if grade >= 60:

print("You earned an D")

if grade < 60:

print("You earned an F")

from grades import (

all_As,

calc_average,

get_grade,

letter_grade

)

# THERE ARE NO ERRORS IN THE MAIN

# YOU DO NOT NEED TO CHANGE THE MAIN

#-----main-----

print("Enter 3 test scores:")

first_test = get_grade()

second_test = get_grade()

third_test = get_grade()

print()

all_As(first_test, second_test, third_test)

average = calc_average(first_test, second_test, third_test)

print("Your test average is",average)

letter_grade(average)

When the program is correct, it should have output like this:

Enter 3 test scores:
Enter your test score >  100
Enter your test score >  90
Enter your test score >  91

Wow! You scored 90 or above on all your exams!
Keep up the As!

Your test average is 93.66666666666667
You earned an A

Solutions

Expert Solution

please observer i have commented in every function

Here is the working code with out errors

# Describe the error found in this function:
## we have to return the input value i.e grade
def get_grade():
    grade = int(input("Enter your test score > "))
    return grade
# Describe the error found in this function:
## in this function after checking if condtion have to give results based on true or false
## here function checking test1,test2,test3 if 3 tests are true will prints the following statements
## here added else case also if all the test score are less than 89
## prints You scored below 90 in one or on all your exams!"
def all_As(test1, test2, test3):
    if test1 > 89 and test2 > 89 and test3 > 89:
        print("Wow! ", end="")
        print("You scored 90 or above on all your exams!")
        print("Keep up the As!")
        print()
    else:
        print("You scored below 90 in one or on all your exams!")
        

# Describe the error found in this function:
## we for finding average sum of tests and devided by number of tests
## here need modify (test1 + test2 + test3) / 3
def calc_average(test1, test2, test3):
    average = (test1 + test2 + test3) / 3
    return average

# Describe the error found in this function:
## in this function we have to be mention the range of grade like more than 90 is A
## grade >= 80 and less than 90 is B
## grade >= 70 and less than 80 is C
## grade >= 60 and less than 70 is D
## grade  less than 60 is E

def letter_grade(grade):
    if grade >= 90:
        print("You earned an A")
    if 80<= grade < 90:
        print("You earned an B")
    if 70 <= grade < 80:
        print("You earned an C")
    if 60 <= grade < 70:
        print("You earned an D")
    if grade < 60:
        print("You earned an F")
        
from grades import (
    all_As,
    calc_average,
    get_grade,
    letter_grade
)

# THERE ARE NO ERRORS IN THE MAIN

# YOU DO NOT NEED TO CHANGE THE MAIN

#-----main-----

print("Enter 3 test scores:")

first_test = get_grade()

second_test = get_grade()

third_test = get_grade()

print()

all_As(first_test, second_test, third_test)

average = calc_average(first_test, second_test, third_test)

print("Your test average is",average)

letter_grade(average)

OUTPUT SCREEN


Related Solutions

Reading code that you haven't written is a skill you must develop. Many times you are...
Reading code that you haven't written is a skill you must develop. Many times you are correcting this code that you didn't write so you have to 1) read the code, 2) find the errors, and 3) correct them. You are going to correct a program that has several errors in it (specifically, one error per function). You should begin by looking at what the expected output of the program should be for various inputs. Then, run the code and...
This code must be written in Java. This code also needs to include a package and...
This code must be written in Java. This code also needs to include a package and a public static void main(String[] args) Write a program named DayOfWeek that computes the day of the week for any date entered by the user. The user will be prompted to enter a month, day, and year. The program will then display the day of the week (Sunday..Saturday). The following example shows what the user will see on the screen: This program calculates the...
Must be written in JAVA Code Modify the program you created in previous project to accomplish...
Must be written in JAVA Code Modify the program you created in previous project to accomplish the following: Support the storing of additional user information: street address (string), city( string), state (string), and 10-digit phone number (long integer, contains area code and does not include special characters such as '(', ')', or '-' Store the data in an ArrayList object Program to Modify import java.util.ArrayList; import java.util.Scanner; public class Address { String firstname; String lastname; int zipcode;    Address(String firstname,String...
The following code must be written using matlab and must be using a for-loop. NOTE! Write...
The following code must be written using matlab and must be using a for-loop. NOTE! Write a computer program that assigns random integers for each entry and generates a row vector. Different random integers should be drawn from different intervals for position 1, position 2, position3 and position 4 of the array. After these first 4 positions are drawn. The whole thing should start over where position5 drawn from same interval as positions 1, position6 drawn from same interval as...
The following code must be written using matlab and must be using a for-loop. NOTE! Write...
The following code must be written using matlab and must be using a for-loop. NOTE! Write a computer program that assigns random integers for each entry and generates a row vector. Different random integers should be drawn from different intervals in chunks of 4 , that is chunk1-chunk2-chunk3-chunk4 The parameters for specifying the lintervals by which the random numbers should be drawn should be able to change and be hardcoded in the script, however, be hardcoded in the script.
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java...
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java program that will solve the following problem. The program uses one and two-dimensional arrays to accomplish the tasks specified below. The menu is shown below. Please build a control panel as follows: (Note: the first letter is shown as bold for emphasis and you do not have to make them bold in your program.) Help SetParams FillArray DisplayResults Quit Upon program execution, the screen...
The following code must be written using matlab How to get the elements that are different...
The following code must be written using matlab How to get the elements that are different in two set without using the setdiff function in matlbab?
The following code must be written in Matlab I want to print the following in Matlab...
The following code must be written in Matlab I want to print the following in Matlab (x1,x2, x3) = (0.33333, 0.33333, 0.33333)  . The whole thing should be on the same line. I need to use fprintf and write out the coordinates with 5 decimal places of variable x = (0.33333, 0.33333, 0.33333) Thanks!
The following code must be written using matlab How to loop through a vector in matlab...
The following code must be written using matlab How to loop through a vector in matlab and assigning a value to every 4th entry. The vector could be of any length. Thanks
VHDL code for a 4 to 2 priority encoder. The structural behavior must be written using...
VHDL code for a 4 to 2 priority encoder. The structural behavior must be written using gates.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT