Get input from the user towrite the following information to a file: Student name Assignment average grade Midterm exam grade Final project grade Final exam grade Allow the user to search the file by...

1 answer below »


  1. Get input from the user towrite the following information to a file:

    1. Student name

    2. Assignment average grade

    3. Midterm exam grade

    4. Final project grade

    5. Final exam grade



  2. Allow the user to search the file by student name and output a weighted average (15%,25%,25%, and35%, respectively)based on the grades for that student in the file.


The user should be able to choose either of the two options until they want to stop.





Answered Same DayOct 16, 2021

Answer To: Get input from the user towrite the following information to a file: Student name Assignment average...

Vaibhav answered on Oct 17 2021
120 Votes
JupyterNotebook.ipynb
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Method searchStudentRecord() is used to search the grades of a student with the specified name. If the record with the
specified name is present, it will return the details. Otherwise returns an empty string."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"def searchStudentRecord(name):\n",
" data = \"\"\n",
" name = name.lower()\n",
" with open(\"studentData.txt\", \"r\") as file:\n",
" for line in file.readlines():\n",
" if(line.find(name) != -1):\n",
" data = line\n",
" break\n",
" file.close()\n",
" return data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Method addStudentRecord() is used to get input from the user to write the information to a file."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def addStudentRecord():\n",
" with open(\"studentData.txt\", \"a\") as file:\n",
" print(\"Enter the details mentioned below\")\n",
" print()\n",
" name = input(\"Enter student name: \")\n",
" name = name.lower()\n",
" print()\n",
" assignmentGrade = float(\n",
" input(\"Enter assignment average grade upto 2 decimal : \"))\n",
" print()\n",
" midtermGrade = float(\n",
" input(\"Enter midterm exam grade upto 2 decimal : \"))\n",
" print()\n",
" finalProjectGrade = float(input(\"Enter final project grade : \"))\n",
" print()\n",
" finalGrade = float(input(\"Enter final exam grade : \"))\n",
" file.write(' '.join(str(i) for i in [\n",
" name, assignmentGrade, midtermGrade, finalProjectGrade, finalGrade]))\n",
" file.write('\\r\\n')\n",
" print(\"Student details successfully added to the file.\")\n",
" file.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### The starting point of the execution. Call this...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here