In Python: So this is part of a large project I am working on but I'm having a hard time finding out how to read from one text file and then correct that information to another or same txt file as well as to do it alphabetically. Any help is appreciated. The code I've added was from a previous project that was similar as to what this one wants.
Problem #1: How much should I study outside of class?
Issue:
Your fellow students liked the 2nd version of study hour’s application and want to expand it again by adding the features listed below.
Minimum Study Hours per Week per Class Grade
15 A
12 B
9 C
6 D
0 F
- Determine Hours to Study
- 2.1 The program will READ in data from a text file named StudyHours.txt. The user corrects any bad data. The program updates the information in StudyHours.txt file. For example if the file contains a letter grade of K which is not a possible letter grade.
StudyHours.txt contains the following data:
- first line full name
- second line number of credits
- third line grade desired for each class
Example format StudyHours.txt file
Aaron RODgers
12
A
Tom brady
9
K
philip Rivers
apple
c
Joe Theismann
15
B
- 2.2 The program determines the total weekly study hours (for all classes)
- 2.3 All data must be displayed in proper case such as Bob Smith, i.e. no names should be in all lower case or all upper case or a mix such as bob or SmiTH. Use a function to convert to proper case.
- 2.4 The program displays the user’s name, number of credits, expected total number of weekly study hours, and desired grade
- 2.5 The information from 2.4 is also appended to a file named StudyHoursGrades.txt in alphabetical order (by firstname) in the following format:
- first line full name
- second line number of credits
- third line study hours
- fourth line grade
Here is the code I have from previous projects:
def studyHours():
#open StudentsHoursGrades.txt
hoursFile = open('StudentsHoursGrades.txt', 'a')
#Ask Student's Name
student = input('Please enter your first and last name: \n')
#Validation that something was entered
while student == "":
print('Please print a valid name. \n')
student = input('Please enter your first and last name: \n')
#Ask how many credit hours they are taking
creditHours = input('How many credit hours are you taking this semester? \n')
#Validate user entered a number
while not creditHours.isdigit() or int(creditHours)%3!= 0:
print('You entered', creditHours,'Credit hours should be divisible by 3 and not exceed 18.')
creditHours = input('How many credit hours are you taking this semester? \n')
#Ask what grade they desire
grade = input('Please enter what letter grade you want to earn: \n')
#Validate user entered a letter for grade
while not((grade >= 'a' and grade <='d') or (grade == 'f') or (grade >='A' and grade <= 'D') or (grade =='F')):
print('Please enter a valid letter grade of A, B, C, D, or F.')
grade = input('Please enter what letter grade you want to earn: \n')
#Calculate study rate
if grade.upper() == 'A':
studyRate = 15
elif grade.upper() == 'B':
studyRate = 12
elif grade.upper() == 'C':
studyRate = 9
elif grade.upper() == 'D':
studyRate = 6
elif grade.upper() == 'F':
studyRate = 0
#Calculate hours per class
classHours = int(creditHours)/3
#Calculate study hours
hours = int(classHours) * studyRate
#write to file
hoursFile.write(str(student) + '\n')
hoursFile.write(str(creditHours) + '\n')
hoursFile.write(str(hours) + '\n')
hoursFile.write(grade + '\n')
#close file
hoursFile.close()
#display on screen
print('Name: ',student)
print('Credits: ',creditHours)
print('Study Hours: ',hours)
print('Letter Grade: ',grade, '\n')
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- Please convert this from Python to C (thank you) def math_game(lv, lmf, lsf, lrf, rv, rmf, rsf, rrf):print('Starting Math Game:')print('[{},{},{},{}] vs [{},{},{},{}]'.format(lv, lmf, lsf, lrf,rv, rmf, rsf, rrf)) counter = 0while counter < 5 and lv < rv:print('Round = {}'.format(counter + 1))lcounter = 0while lcounter < lrf:lv = lv*lmf - lsfprint('L = {}'.format(lv))lcounter += 1rcounter = 0while rcounter < rrf:rv = rv*rmf - rsfprint('R = {}'.format(rv))rcounter += 1counter += 1print('Closing Math Game')if counter == 5:winner = 'R'else:winner = 'L'return winnerarrow_forwardA vector in Matlab has magnitude and direction is an array with only one column or one row is a table of numbers contains at most three numbers, one for each dimension. When adding two arrays in Matlab the arrays only need to have the same number of elements the arrays must have the exact same size and shape you need to put a period in front of the plus sign both b and c are true When combining a scalar c to an array A with a command like c + A Matlab adds the c to every element in A an error is displayed because the dimensions are different the result will be different than the command A + carrow_forwardDetails are in the picturesarrow_forward
- Coding in python Please!!I need help please help me in the easiest way to do this coding question. Please do not post it's answer from chegg just use your own skills to write code in easyiest way possible. I will really appriciate your help. Coding language PYTHON : The purpose of this assignment is to help you get comfortable creating and using simple classes and objects. In this assignment, we wish to model a 2-D video game character’s movements. In particular, suppose we are creating a tiny game, where the character can occupy one of 25 squares, like so: The first thing we need to keep track of is the character’s name, so we can differentiate this character from other characters or enemies. The other thing we need to keep track of is the character’s position, i.e., which square they are in. In order to do this, we’ll use an X-Y coordinate system with the origin in the top left corner (the 0,0 square in the picture). So, in the picture, the character occupies square 3, 2;…arrow_forwardProblem #1: How much should I study outside of class? Issue: Your fellow students liked the previous version of study hour’s application and want to expand it again by adding the features listed below. Minimum Study Hours per Week per Class Grade15 A12 B9 C6 D0 F Project Specifications: The program asks the user their name, employee id, and department. The program also asks the user who they are creating the report for, their employee id, and the department they work in. (hint #1 & 2 are instances of a class – A class must be created and used within the program)The menu driven program has the following options:Determine Hours to StudyDetermine Grade Display Averages and TotalsQuit The user can select any menu option in any order they want. For example:The user can start the program run option A, then option C, then option B, then option D. They restart the program, run option C, then D. They restart the program, run option A, then D. They restart…arrow_forwardLook over Python assignment and answer one question. Hi, I have attached both the assignment directions and a copy of my work so far. I wanted to make sure I was properly explaining the results. I also don't understand why the last print statement, print(2//3) has a result of zero instead of 8. Thanks so much.arrow_forward
- Help write a C++ Program to do the following: This is to create a prototype for a Web browser. You’ll do this by transforming the file viewer created (SHOWN BELOW) into a browser for a web of files that are all located on a single computer. (This is in contrast to the real World Wide Web whose pages are located all over the world.) Details The files in this web of files are plain text files that may contain anchors that provide links to other files. More precisely, an anchor is a string of the form 1 where filename is the name of another file and text is a piece of text. For example, here’s a line of text that contains an anchor: More is available. To keep things simple, assume that every anchor is separated from adjacent text by white space and that the strings filename and text cannot contain white space. Your browser should work exactly like the file viewer, except for the following: 1. When an anchor is displayed, it should appear as [n] where n is a number that is unique to…arrow_forwardCourse: Data Structurre and algorithms Language: Java Make a Program in java may be simple but do something please you can take time of 3 to 5 hours. Read the pics properly its easy but explained in theory. You have to solve ( make program ) the question by properly as you can. Kindly make it unque dont copy paste. Make programe dont make excusses for rejection I want to take trial but you are not doing anything: Question: Implement a struct Node which has two data members, aninteger variable named“data” and one node pointer named "next”. structNode { int data; Node next; } Now using the above Node implementation, implement a Singly linked list named “SlinkedList” which can store member named size which contains the length of the list.positive integer only.SlinkedList class also contains an integer data You have to implement the following member functions for SlinkedListclassYou must use recursion wherever specified.. You can make any helper member functions if you need): A default…arrow_forwardCan you please help me modify this program as in the instructions in the red circle? This is a java program. I need the output to be the same as in the example picture (same picture with the red circle)arrow_forward
- Question 2- Converting a Design into Python Code . The answer to this question should be filled in in the "Question2" file on Replit. Below, you have been given the design for a program that helps determine the power required to operate three devices. Use the design below to produce the equivalent Python code for this program. Note: DO NOT change the design of the program in any way. Even if you don't like it, make sure that the Python code you produce matches the design below. Display "Welcome. This program helps you determine the power required to operate three devices." Read in the power rating of the first device in watts; convert into an int and store into variable rating1 • Read in the power rating of the first device in watts; convert into an int and store into variable rating2 Read in the power rating of the first device in watts; convert into an int and store into variable rating3 Read in the available power in kilowatt-hours; convert into a float and store into variable…arrow_forwardOne of the files is the instructions. One is what I have so far. My question's are: I'm confused about what they mean by holds the following data attributes. Do I write any code for that? ALSO: for list of number of gear teeth values- I'm not sure what they mean by should have a length equal to... etc. How would I write that in python? Thanksarrow_forwardHelp me on the python programarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education