Question

In: Computer Science

Python Code: Write a program to prompt the user to enter a first name, last name,...

Python Code:

  1. Write a program to prompt the user to enter a first name, last name, student ID, number of hours completed and GPA for 5 students. Use a loop to accept the data listed below. Save the records in a text file.
  2. Write a second program that reads the records from your new text file, then determines if the student qualifies for Dean’s list or probation. Display the records read from the file on screen with appropriate headings above the data being displayed. Save screenshot for submission.

If the GPA is >= 3.5, display 'Dean’s List'

If the GPA is < 2.0, display 'Dismissed’

If the GPA is < 3.5 and >= 2.0, display 'Regular Standing'

The data is as follows:

Mohammed James   012345 94 3.2  

Priya Jones 112245 45 3.9

George Wayne   013265 18 1.9

Jennifer Fulton   121378 30 2.0

Ayesha Smith       043245 64 3.5

Solutions

Expert Solution

Answer 1:(code for first file)

class Student(object):

def __init__(self, fname, lname, stud_id, hours, gpa):

self.name = fname + ' ' + lname

self.stud_id = stud_id

self.hours = hours

self.gpa = gpa

def getgpa(self):

return self.gpa

def getid(self):

return self.stud_id

def gethours(self):

return self.hours

def __str__(self):

return self.name + ' : ' + str(self.getid()) +' ::' + str(self.gethours()) +' :: '+ str(self.getgpa())

# Defining a function for building a Record

# which generates list of all the students


def Markss(Record, fname, lname, stud_id, hours, gpa):

Record.append(Student(fname, lname, stud_id, hours, gpa))

return Record

# Main Code

Record = []

x = 'y'

while x == 'y':

fname = input('Enter the first name of the student: ')

lname = input('Enter the last name of the student: ')

stud_id = input('Enter the student id: ')

hours = input('Hours: ')

gpa = input('GPA: ')

Record = Markss(Record, fname, lname , stud_id, hours, gpa)

RecordForFile = fname + ' ' + lname + ' ' + stud_id + ' ' + hours + ' ' + gpa

file = open('read.txt', 'a+')

newRec = str(RecordForFile)

file.write(newRec+ "\n")

file.close()

x = input('another student? y/n: ')

# Printing the list of student

n = 1

for el in Record:

print(n,'. ', el)

n = n + 1

Output:

Answer 2:(Code for second file)

print ("FirstName LastName StudId Hours GPA Qualification")

file1 = open("read.txt","r+")

Record = file1.read()

x = Record.split()

n=1

for el in x:

if n == 6 or n == 11 or n == 21:

print(el, end='\t ')

else:

print(el, end='\t')

if n % 5 == 0 :

if float(el) >= 3.5:

print("Dean's List")

elif float(el) < 2.0 :

print("Dismissed")

elif float(el) < 3.5 and float(el) >= 2.0 :

print("Regular Standing")

n=n+1

Output:


Related Solutions

PYTHON Modify the program in section Ask the user for a first name and a last...
PYTHON Modify the program in section Ask the user for a first name and a last name of several people.  Use a loop to ask for user input of each person’s first and last names  Each time through the loop, use a dictionary to store the first and last names of that person  Add that dictionary to a list to create a master list of the names  Example dictionary: aDict = { "fname":"Douglas", "name":"Lee" } ...
Write a program function code in Python that prompts the user to enter the total of...
Write a program function code in Python that prompts the user to enter the total of his/her purchase and add 5% as the VAT. The program should display the total without and with VAT. ( that mean i should ask the user to enter the number of their item " so i think that i should use range" then print the result with and without the VAT )
Write a Python program that has the user enter their name.   Using the user's name calculate...
Write a Python program that has the user enter their name.   Using the user's name calculate the following: 1. How many letters are in the user's name? 2. Print the user's name in REVERSE both in capital letters and lowercase letters 3. Print the ASCII value for each letter of the user's name. 4. Print the SUM of all of the letters of the user's name (add each letter from #3)
Please write the code JAVA Write a program that allows the user to enter the last...
Please write the code JAVA Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is: Candidate      Votes Received                                % of Total Votes...
First, the Python program prompts user to enter user information (name, email, and phone number). Then...
First, the Python program prompts user to enter user information (name, email, and phone number). Then it displays a menu called “Fish Information” that has the following fish type: 1. Cat Fish 2. Red Fish 3. Any other fish Let user choose the fish type that he/she got and input the length of the fish. Then the program will determine what should be done with this particular fish. Based on the following criteria: Criteria: Length: FISHTYPE - Cat Fish <10:...
C++ Code Writing prompt: Grade Calculation: Write a program that asks the user to enter in...
C++ Code Writing prompt: Grade Calculation: Write a program that asks the user to enter in a number greater than or equal to zero and less than or equal to 100. If they do not you should alert them and end the program. Next, determine the letter grade associated with the number. For example, A is any grade between 90 and 100. Report the letter grade to the user.
Write a Python program that asks the user to enter a student's name and 8 numeric...
Write a Python program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name will be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name. Write the following functions in the program: calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student determine_grade -...
PYTHON Write a program that asks the user to enter a student's name and 8 numeric...
PYTHON Write a program that asks the user to enter a student's name and 8 numeric assignment scores (out of 100 for each assignment). The program should output the student's name, a letter grade for each assignment score, and a cumulative average for all the assignments. Please note, there are 12 students in the class so your program will need to be able to either accept data for 12 students or loop 12 times in order to process all the...
Write a python program that asks the user to enter a student's name and 6 numeric...
Write a python program that asks the user to enter a student's name and 6 numeric tests scores (out of 100 for each test). The name will be a global variable. Create functions to calculate a letter grade for the student and calculate the average of the test scores for the student. The program should display a letter grade for each score, and the average test score, along with the student's name. Assume 6 students in the class. Functions in...
Write a PYTHON program that asks the user to enter a student's name and 8 numeric...
Write a PYTHON program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name will be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name. Write the following functions in the program: calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student. determine_grade -...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT