Skip to content

ODea-High-School/python-grade-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Programming: Grade analysis

I. Learner Objectives

Upon completion of this assignment, students should be able to:

  • Open and close files
  • Read from, write to, and update files
  • Manipulate file handles
  • Apply standard library functions: open(), close(), read(), write()
  • Compose decision statements (if conditional statements)
  • Create and utilize compound conditions

II. Prerequisites

Before starting this assignment, students should be able to:

  • Analyze a basic set of requirements and apply top-down design principles
  • Define and use Python functions
  • Implement guard code using if __name__ == "__main__":
  • Summarize topics including:
    • What is a selection or conditional statement?
    • What is a compound condition?
    • What is a Boolean expression?

III. Overview & Requirements

Write a Python program that processes numbers corresponding to student records read from a file and writes the required results to an output file.

Function Specifications

Implement the following functions:

  1. read_student_record(file): Reads a line from the input file and returns a tuple (gpa, class_standing, age) as floats/ints.
  2. calculate_sum(numbers): Returns the sum of the provided numbers (accepts a list of numeric arguments). Returns -1.0 if the list is empty.
  3. calculate_mean(numbers): Returns the mean of the numbers. Returns -1.0 if the list is empty.
  4. calculate_deviation(number, mean): Returns the deviation as number - mean.
  5. calculate_variance(numbers, mean): Returns the variance as the average of squared deviations from the mean. Returns -1.0 if the list is empty.
  6. calculate_standard_deviation(variance): Returns the standard deviation as the square root of the variance.
  7. find_max(numbers): Returns the maximum value in a list of numbers
  8. find_min(numbers): Returns the minimum value in a list of numbers
  9. print_float(file, number, decimals=2): Writes a floating-point number to the output file (expects a file object opened for writing), formatted to the specified number of decimal places (default is 2).

Main Function Requirements

The main() function should:

  • Open an input file named input.csv for reading.
  • Open an output file named output.dat for writing.
  • Read five student records from input.csv. Each record includes:
    • GPA
    • Class standing
    • Age
  • Calculate the sum and mean for GPAs, class standings, and ages.
  • Calculate the deviation of each GPA from the mean GPA.
  • Calculate the variance and standard deviation of the GPAs.
  • Determine the minimum and maximum GPA values.
  • Write the results to output.dat.
  • Close both the input and output files.

IV. Input File Format

The input file input.dat should contain five student records, each on a separate line with the following format:

<GPA> <ClassStanding> <Age>

Example:

3.5 2 20
3.8 3 21
2.9 1 19
3.2 4 22
3.7 2 20

V. Output File Format

The output file output.dat should contain the calculated statistics with appropriate labels.

Example:

Mean GPA: 3.42
Mean Class Standing: 2.4
Mean Age: 20.4
GPA Standard Deviation: 0.34
Minimum GPA: 2.9
Maximum GPA: 3.8

VI. Submission Instructions

  • Submit your solution by pushing your code to the GitHub Classroom repository provided for this assignment.
  • Make sure all your code, including main.py, your README.md, and any other required files, are committed and pushed to your GitHub Classroom repository.
  • Ensure your submission includes all necessary files to run your program and that your code runs as expected from the repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages