In python, Im not getting an output for this code.
import csv
tsv_name=input("Enter tsv file name : ")
tsv_file=open(tsv_name)
read_tsv = csv.reader(tsv_file, delimiter="\t")
f=open("report.txt","w")
student_cnt=0
m1_avrg=0
m2_avrg=0
fexam_avrg=0
for row in read_tsv:
student_cnt+=1
lname=row[0]
fname=row[1]
m1=int(row[2])
m2=int(row[3])
fexam=int(row[4])
avrg=(m1+m2+fexam)/3
grade=" "
if(avrg>=90.0):
grade="A"
elif(avrg>=80.0):
grade="B"
elif(avrg>=70.0):
grade="C"
elif(avrg >=60.0):
grade="D"
else:
grade="F"
f.write("%s\t%s\t%d\t%d\t%d\t%s\n"%(lname,fname,m1,m2,fexam,grade))
m1_avrg+=m1
m2_avrg+=m2
fexam_avrg+=fexam
m1_avrg=(m1_avrg/student_cnt)
m2_avrg=(m2_avrg/student_cnt)
fexam_avrg=(fexam_avrg/student_cnt)
f.write("Averages: midterm1 {0:.2f},\tmidterm2 {1:.2f},\tfinal {2:.2f}".format(m1_avrg,m2_avrg,fexam_avrg))
f.close()
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images
- Creat a text file and run the code to display.(on each text file) Sample lab2_codeBook_input.txt sample lab2_decrypted.txt[0,2] aba aa[2,4,1] bcasa aac[2,1,5,0] retire teer[2,1,5,7] retire Nonearrow_forwardTraceback (most recent call last): File "C:/app.py", line 20, in main() File "C:/app.py", line 17, in main print_report() File "C:/app.py", line 12, in print_report print_id() File "C:/app.py", line 6, in print_id message = "Your id is:" + id num TypeError: must be str, not int Process finished with exit code 1 Given this stack trace above, on what line was the exception raised? O Line 17 O Line 12 O Line 6 O Line 20arrow_forwardIn C++ Create a program that outputs 10 strings (that the user inputs) to a file.arrow_forward
- Please help with my C++Specifications • For the view and delete commands, display an error message if the user enters an invalid contact number. • Define a structure to store the data for each contact. • When you start the program, it should read the contacts from the tab-delimited text file and store them in a vector of contact objects. •When reading data from the text file, you can read all text up to the next tab by adding a tab character ('\t') as the third argument of the getline() function. •When you add or delete a contact, the change should be saved to the text file immediately. That way, no changes are lost, even if the program crashes laterarrow_forwardCode in C language. Please provide code for 3 different files. One header file and two .C files. I need the code for each file. Please provide photos of the output and source code for each file (3). Please follow All instructions in the photo provided. Use the provided input.txt file provided below. A1, A2 20294 Lorenzana Dr Woodland Hills, CA 91364 B1, B2 19831 Henshaw St Culver City, CA 94023 C1, C2 5142 Dumont Pl Azusa, CA 91112 D1, D2 20636 De Forest St Woodland Hills, CA 91364 A1, A2 20294 Lorenzana Dr Woodland Hills, CA 91364 E1, E2 4851 Poe Ave Woodland Hills, CA 91364 F1, F2 20225 Lorenzana Dr Los Angeles, CA 91111 G1, G2 20253 Lorenzana Dr Los Angeles, CA 90005 H1, H2 5241 Del Moreno Dr Los Angeles, CA 91110 I1, I2 5332 Felice Pl Stevenson Ranch, CA 94135 J1, J2 5135 Quakertown Ave Thousand Oaks, CA 91362 K1, K2 720 Eucalyptus Ave 105 Inglewood, CA 89030 L1, L2 5021 Dumont Pl Woodland Hills, CA 91364 M1, M2 4819 Quedo Pl Westlake Village, CA 91362 I1, I2 5332 Felice Pl…arrow_forwardI am looking to write two python programs for golf data. The Westminster Amateur Golf Club has a tournament every weekend. The club president has askedyou to design and write two programs. The first program will read each player's name and golf score as keyboard input, and then save(append) these records in a file named golf.dat (Each record will have a field for the player'sname and a field for the player's score, separated by commas). The second program will read the records from the golf.dat file and displays them. n addition, italso displays the name of the player with the best (lowest) score. The output should look like this: Program 1Enter a player's name: Larry FineEnter the player's score: 20Do you want to enter another record?Enter y for yes or anything else for no: y Enter a player's name: Moe HowardEnter the player's score: 21Do you want to enter another record?Enter y for yes or anything else for no: y Enter a player's name: Curly HowardEnter the player's score: 22Do you…arrow_forward
- User Input Program and Analysis (Last answer to this question was incorrect.) Demonstrate an understanding of C++ programming concepts by completing the following: Program: Create a C++ program that will obtain input from a user and store it into the provided CSC450_CT5_mod5.txt Download CSC450_CT5_mod5.txtfile. Your program should append it to the provided text file, without deleting the existing data: Store the provided data in the CSC450_CT5_mod5.txt file. Create a reversal method that will reverse all of the characters in the CSC450_CT5_mod5.txt file and store the result in a CSC450-mod5-reverse.txt file. Program Analysis: Given your program implementation, discuss and identify the possible security vulnerabilities that may exist. If present, discuss solutions to minimize the vulnerabilities. Discuss and identify possible problems that can result in errors for string manipulation of data. Your analysis should be 1-2 pages in length. TXT FILE INFORMATION (Txt file should NOT…arrow_forwardFilename: runlength_decoder.py Starter code for data: hw4data.py Download hw4data.py Download hw4data.pyYou must provide a function named decode() that takes a list of RLE-encoded values as its single parameter, and returns a list containing the decoded values with the “runs” expanded. If we were to use Python annotations, the function signature would look similar to this:def decode(data : list) -> list: Run-length encoding (RLE) is a simple, “lossless” compression scheme in which “runs” of data. The same value in consecutive data elements are stored as a single occurrence of the data value, and a count of occurrences for the run. For example, using Python lists, the initial list: [‘P’,‘P’,‘P’,‘P’,‘P’,‘Y’,‘Y’,‘Y’,‘P’,‘G’,‘G’] would be encoded as: ['P', 5, 'Y', 3, ‘P’, 1, ‘G’, 2] So, instead of using 11 “units” of space (if we consider the space for a character/int 1 unit), we only use 8 “units”. In this small example, we don’t achieve much of a savings (and indeed the…arrow_forwardWrite a program in C++ that creates a file. Write this data into that file column wise as a header. Then keep adding data in colum wise format. The program should check if there is data in the file and then write the data in the next row. First add: TIME DAY MONTH YEAR Then check the file and add: 01:25 07 JUNE 2008 Then check again the file and add this in next row: 14:00 30 MARCH 2019arrow_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