Use python
Start:
def main():
gradeList = []
fileName = getFile()
gradeList = getData(fileName)
mean = calculateMean(gradeList)
sd = calculateSD(mean, gradeList)
displayHeadings(gradeList, mean, sd)
curveGrades(mean, sd, gradeList)
if __name__ == "__main__":
main()
===============================================================
Python Script to copy:
# Python script to assign letter grade for given grade
import math # To use sqrt function
# Function to get filename from user
def getFile():
filename = input("Enter the filename: ")
return filename
# Function to read data from input file
def getData(filename):
fin = open(filename, "r") # Open the input file
line = fin.readline() # Read the first line in file
grades = [] # Initializing list to store grades in input file
while line != "":
grades.append(float(line.strip())) # Adding every grade value to list
line = fin.readline() # Read the next line in file
return grades
# Function to calculate Mean for given data
def calculateMean(gradeList):
total = 0
for each in gradeList:
total += float(each)
mean = total / len(gradeList)
return mean;
# Function to calculate standard deviation for given data
def calculateSD(mean, gradeList):
total = 0
for i in gradeList:
total += (float(i) - mean)**2 # ** indicates value to the power i.e, x*x
stdev = total / (len(gradeList)-1)
return math.sqrt(stdev);
# Function to display titles or headings of output data
def displayHeadings(gradeList, mean, sd):
print("Number of grades: ",len(gradeList))
print("Mean: ",mean)
print("Standard Deviation: ",'{:.4f}'.format(sd))
print("\n\t",'{:7s}'.format("Score Grade"))
# Function to assign letter grade for respective grade
def curveGrades(mean, sd, gradeList):
slno = 1 # Variable to represent serial number
for grade in gradeList:
# Calculate the letter grade
if grade >= (mean + 1.5*sd):
letterGrade = 'A'
elif grade >= (mean + 0.5*sd) and grade < (mean + 1.5*sd):
letterGrade = 'B'
elif grade >= (mean - 0.5*sd) and grade < (mean + 0.5*sd):
letterGrade = 'C'
elif grade >= (mean - 1.5*sd) and grade < (mean - 0.5*sd):
letterGrade = 'D'
elif grade < (mean - 1.5*sd):
letterGrade = 'F'
print('{:2d}'.format(slno),'{:7.2f}'.format(grade),letterGrade.rjust(3," "))
slno += 1 # Incrementing serial number
# Main function to test all functions above
def main():
gradeList = []
fileName = getFile()
gradeList = getData(fileName)
mean = calculateMean(gradeList)
sd = calculateSD(mean, gradeList)
displayHeadings(gradeList, mean, sd)
curveGrades(mean, sd, gradeList)
if __name__ == "__main__":
main()
---------------------------------------------------
Python script screenshots:
------------------------------------------------------------------
Sample Input:
File name: input.txt
-------------------------------------------------------
Sample Output:
===================================================================
Hope it will helpfull and do comments for any additional info if needed. Thankyou
===================================================================
Use python Start: def main(): gradeList = [] fileName = getFile() gradeList = getData(fileName) mean...
Write a Python Program Preview File Edit View Go Tools Window OO 95% Help An Intro to Programming Using Python (2) (1) (1).pdf (page 256 of 431) Mon 11:28 AM Q E © Q Search 2. Curve Grades Statisticians use the concepts of mean and standard deviation to describe a collection of numbers. The mean is the average value of the numbers, and the standard deviation measures the spread or dispersal of the numbers about the mean. Formally, if X1,...
C++ Use C++ functions and build a program that does the most basic job all students have to contend with, process the grades on a test and produce a summary of the results. The big wrinkle is, it should be a multi-file program. -Requires three simple things: Figure out the best score of all scores produced Figure out the worst score of all scores produced Assign a letter grade for each score produced Complete this lab by writing three functions....
I really need help with this python programming assignment Program Requirements For part 2, i need the following functions • get floats(): It take a single integer argument and returns a list of floats. where it was something like this def get_floats(n): lst = [] for i in range(1,n+1): val = float(input('Enter float '+str(i)+': ')) lst.append(val) return lst • summer(): This non-void function takes a single list argument, and returns the sum of the list. However, it does not use...
PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything a course uses in a grading scheme, # like a test or an assignment. It has a score, which is assessed by # an instructor, and a maximum value, set by the instructor, and a weight, # which defines how much the item counts towards a final grade. def __init__(self, weight, scored=None, out_of=None): """ Purpose: Initialize the GradeItem object. Preconditions: :param weight: the weight...
Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...
Hi. Could you help me write the below program? Please don't use any header other than iostream, no Chegg class, no argc/argv. Nothing too advanced. Thank you! For this assignment you are implement a program that can be used to compute the variance and standard deviation of a set of values. In addition your solution should use the functions specified below that you must also implement. These functions should be used wherever appropriate in your solution. With the exception of...
Python 3 Question Do NOT use global variables (This is an edit to a question I've asked before because I forgot to include a template. So if you have answered this question already I ask that you do not copy and paste a previous answer.) PLEASE use the template given, keep the code introductory friendly, and include comments. Many thanks. Prompt: The results of a survey of the households in your township are available for public scrutiny. Each record contains...
I need this in C++. This is all one question. Introduction Your eighth assignment will consist of two programs, which will involve the use of simple classes. The source code for these problems should be submitted using the naming conventions we specified in class. Please note that your computer programs should comply with the commenting and formatting rules as described in class. For example, there should be a header for the whole program that gives the author's name, class name,...