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 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...
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.
Please write in Python code please: Write a program that asks the user to enter 5...
Please write in Python code please: Write a program that asks the user to enter 5 test scores between 0 and 100. The program should display a letter grade for each score and the average test score. You will need to write the following functions, including main: calc_average – The function should accept a list of 5 test scores as an input argument, and return the average of the scores determine_grade – The function should accept a test score as...
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...
IN C This assignment is to write a program that will prompt the user to enter...
IN C This assignment is to write a program that will prompt the user to enter a character, e.g., a percent sign (%), and then the number of percent signs (%) they want on a line. Your program should first read a character from the keyboard, excluding whitespaces; and then print a message indicating that the number must be in the range 1 to 79 (including both ends) if the user enters a number outside of that range. Your program...
---- Python CIMP 8A Code Lab 4 Write a program that asks the user to enter...
---- Python CIMP 8A Code Lab 4 Write a program that asks the user to enter 5 test scores. The program will display a letter grade for each test score and an average grade for the test scores entered. The program will write the student name and average test score to a text file (“studentgrades.txt”). Three functions are needed for this program. def letter_grade( test_score) Test Score Letter Grade 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F...
In python Write the code to ask a user to enter a number in the range...
In python Write the code to ask a user to enter a number in the range of 1-100. Have the code checked to make sure that it is in this range. If it is not, let the user re-enter the number. The user should be able to re-enter numbers until the number is within the correct range.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT