Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to complete this assignment. I am not able to get PyCharm to show my output . txt file. What can I do

I am trying to complete this assignment. I am not able to get PyCharm to show my output .txt file. What can I do to fix this?
import datetime
def findGrade(test_avrg):
grade =''
if test_avrg >=90:
grade ='A'
elif 80<= test_avrg <90:
grade ='B'
elif 70<= test_avrg <80:
grade ='C'
elif 60<= test_avrg <70:
grade ='D'
elif test_avrg <60:
grade ='F'
return grade
# program will start from main function
if __name__=='__main__':
student_data_dict = dict()
now = datetime.datetime.now()
current_date_time = now.strftime("%m/%d/%Y %H:%M:%S")
college = "Chattahoochee Technical College"
term = "Fall 2019"
instructor ="Dr. Jerry Mamo"
isMoreDataToEnter = True
while isMoreDataToEnter:
student_temp_dict = dict()
studentId = int(input("Enter the student Id : "))
if studentId <100001:
print("Please enter valid student Id. Try again! ")
continue
first_name = input("Enter first name : ")
last_name = input("Enter last name : ")
test_1= int(input("Enter Test 1 number : "))
test_2= int(input("Enter Test 2 number : "))
test_3= int(input("Enter Test 3 number : "))
test_average =(test_1+ test_2+ test_3)/3
test_average = round(test_average, 2)
grade = findGrade(test_average)
student_temp_dict["First Name"]= first_name
student_temp_dict["Last Name"]= last_name
student_temp_dict["Test 1"]= test_1
student_temp_dict["Test 2"]= test_2
student_temp_dict["Test 3"]= test_3
student_temp_dict["Test Average"]= test_average
student_temp_dict["Grade"]= grade
student_data_dict[studentId]= student_temp_dict
flag = input("Do you want enter more record Y or N ")
if flag.lower()=='n':
isMoreDataToEnter = False
with open("student_data.txt","w") as out:
out.write("College: "+ college +"")
out.write("Term: "+ term +"")
out.write("Instructor: "+ instructor +"")
out.write("Date: "+ str(current_date_time)+"")
for studentid, idDict in student_data_dict.items():
out.write("Student Id: "+ str(studentid)+"")
for key, value in idDict.items():
out.write(key +": "+ str(value)+"")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analytics Systems Engineering Cybersecurity Project Management

Authors: Christopher Greco

1st Edition

168392648X, 978-1683926481

More Books

Students also viewed these Databases questions