Question

In: Computer Science

Write an IPO diagram and Python program that has two functions, main and determine_grade. main –...

Write an IPO diagram and Python program that has two functions, main and determine_grade.

main – Should accept input of five numeric grades from the user USING A LOOP.   It should then calculate the average numeric grade.    The numeric average should be passed to the determine_grade function.

determine_grade – should display the letter grade to the user based on the numeric average:

       Greater than 90: A

80-89:                 B

70-79:                 C

60-69:              D

Below 60:           F

Modularity: Your program should contain 2 functions:   a main function to accept input from the user and calculate average and a second function to display the letter grade.

Input Validation: The test scores entered by the user should be in the range 1-100

Output:   Display both the numeric average (rounded to two decimals) and the letter grade

Sample Dialog:  

Enter score #1 in range 1-100: 900

Error: Re-enter score #1 in range 1-100: 90

Enter score #2 in range 1-100: 65

Enter score #3 in range 1-100: 98

Enter score #4 in range 1-100: 33

Enter score #5 in range 1-100: 75

Your average is: 72.20 which is a(n) C

Solutions

Expert Solution

Python Code:-

def determine_grade(n): #Function
  if(n>=90):
    print("Your average is %.2f which is an A" %n)
  elif(n>=80):
    print("Your average is %.2f which is a B"  %n)
  elif(n>=70):
    print("Your average is %.2f which is a C" %n)
  elif(n>=60):
    print("Your average is %.2f which is a D" %n)
  else:
    print("Your average is %.2f which is a F" %n)



if __name__ == "__main__": #Main function
  total=0
  avg=0
  for i in range(5):
    x=int(input("Enter score #%d in range 1-100: " %(i+1)))
    while True:
      if(x>=1 and x<=100): #Validation
        total=total+x
        break
      else:
        x=int(input("Re-Enter score #%d in range 1-100: " %(i+1)))
  avg=total/5
  determine_grade(avg) #Passing average grade to the function determine grade

I am attaching the Screenshot of the code snippet with output as well below:-

Input-process-output(IPO) diagram:-


Related Solutions

C++ Write a program that has two functions. The 1st function is the main function. The...
C++ Write a program that has two functions. The 1st function is the main function. The main function should prompt the user for three inputs: number 1, number 2, and an operator. The main function should call a 2nd function called calculate. The 2nd function should offer the choices of calculating addition, subtraction, multiplication, and division. Use a switch statement to evaluate the operator, then choose the appropriate calculation and return the result to the main function.
Language Python with functions and one main function Write a program that converts a color image...
Language Python with functions and one main function Write a program that converts a color image to grayscale. The user supplies the name of a file containing a GIF or PPM image, and the program loads the image and displays the file. At the click of the mouse, the program converts the image to grayscale. The user is then prompted for a file name to store the grayscale image in.
python code Write a simple calculator: This program must have 9 functions: •main() Controls the flow...
python code Write a simple calculator: This program must have 9 functions: •main() Controls the flow of the program (calls the other modules) •userInput() Asks the user to enter two numbers •add() Accepts two numbers, returns the sum •subtract() Accepts two numbers, returns the difference of the first number minus the second number •multiply() Accepts two numbers, returns the product •divide() Accepts two numbers, returns the quotient of the first number divided by the second number •modulo() Accepts two numbers,...
In this assignment, you are going to write a Python program to demonstrate the IPO (Input-Process-Output)...
In this assignment, you are going to write a Python program to demonstrate the IPO (Input-Process-Output) cycle that is the heart of many imperative programs used for processing large amount of data. Daisy is recently hired by a warehouse. One of her job is to keep track the items ordered by all the branches of the company. The company wants to automate the task using a computer program. Being a friend of Daisy, she knows you are a Computer Science...
Using python Write a program that has 3 functions, named write_to_file, read_from_file, and ask_user. The write_to_file...
Using python Write a program that has 3 functions, named write_to_file, read_from_file, and ask_user. The write_to_file function should have 2 parameters, file_name and data. When called, the function will open a file with the name stored in the file_name variable, write the information stored in data, then close the file. The read_from_file function will have 1 parameter, file_name. When called, the function will open a file with the name stored in the file_name variable, print the contents of the file,...
Write a Python program to implement one studied entropy coding method, including two separate functions for...
Write a Python program to implement one studied entropy coding method, including two separate functions for encoding and decoding. Use the lyrics of your favorite song as the message to be processed, and test the program on the message. Include the source code, and detail the program design and execution procedure in this section.
In C++ Prototype your functions above "main" and define them below "main"; Write a program that...
In C++ Prototype your functions above "main" and define them below "main"; Write a program that uses two identical arrays of at least 20 integers. It should call a function that uses the bubble sort algorithm to sort one of the arrays in ascending order. The function should keep count of the number of exchanges it makes. The program then should call a function that uses the selection sort algorithm to sort the other arrays. It should also keep count...
Write a C++ program which consists of several functions besides the main() function. The main() function,...
Write a C++ program which consists of several functions besides the main() function. The main() function, which shall ask for input from the user (ProcessCommand() does this) to compute the following: SumProductDifference and Power. There should be a well designed user interface. A void function called SumProductDifference(int, int, int&, int&, int&), that computes the sum, product, and difference of it two input arguments, and passes the sum, product, and difference by-reference. A value-returning function called Power(int a, int b) that...
In C++ prototype functions above "main" and define them below "main"; Write a program that uses...
In C++ prototype functions above "main" and define them below "main"; Write a program that uses two identical arrays of at least 20 integers. It should call a function that uses the bubble sort algorithm to sort one of the arrays in ascending order. The function should keep count of the number of exchanges it makes. The program then should call a function that uses the selection sort algorithm to sort the other arrays. It should also keep count of...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table. A: 90% - 100% B 80% - 89% C 70% - 79% D 60% - 69% F <60% The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT