Python 3.7.2 (Please comment on code and post screenshot of your source code. Thanks)
class1:
while True:
try:
filename = input("Enter
a class to grade (i.e. class1 for class1.txt): ")
filenametxt = filename +
".txt"
f =
open(filenametxt,"r")
#file=f.read()
except:
print("File cannot be
found.")
print()
else:
print("Successfully
opened ", filenametxt,sep='')
print()
break
file = f.read()
splitdata = file.split("\n")
#print(splitdata)
#for line in splitdata:
# splitline = line.split(",")
print("**** ANALYZING ****")
print()
#count = 0
#N = 0
#invalid=0
answerkey =
"B,A,D,D,C,B,D,A,C,C,D,B,A,B,A,C,B,D,A,C,A,A,B,D,D"
answerkey = answerkey.split(",")
invalid = 0
good = 0
grades = [ ]
valid_lines = []
final = []
for line in splitdata:
splitline = line.split(",")
count = 0
N = 0
invalid_line = 0
for each in splitline:
# good +=1
#print(each)
if count == 0:
if each[0] != "N" or len(each) != 9 or each[1:].isnumeric() ==
False:
print("Invalid line of data: N# is invalid")
print(splitline)
print()
invalid += 1
invalid_line += 1
#continue
count+=1
if count != 26:
print("Invalid line of
data: does not contain exactly 26 values:")
print(splitline)
print()
invalid += 1
invalid_line += 1
if invalid_line == 0:
valid_lines.append(splitline)
good += 1
final.append(splitline[0])
if invalid == 0:
#if good == len(splitline) and N == 1
print("No errors found!")
print()
print("**** REPORT ****")
print()
print("Total valid lines of data:",good)
print("Total invalid lines of data:",invalid)
print()
for splitline in valid_lines:
correct = 0
for i in range(len(splitline)-1):
if splitline[i+1] ==
answerkey[i]:
correct +=4
elif splitline[i+1] ==
"":
correct += 0
elif splitline[i+1] !=
answerkey[i]:
correct -= 1
grades.append(correct)
grades2 = []
for grade in grades:
grades2.append(grade)
grades2.sort()
sum_of_grades = sum(grades)
avg = (sum_of_grades / len(grades))
print("Mean (average) score:",format(avg,".2f"))
print("Highest score:",max(grades))
print("Lowest score:",min(grades))
print("Range of scores:", (max(grades) - min(grades)))
if len(grades) % 2 != 0:
grades2.sort()
print("Median
score:",grades2[int(len(grades)//2+1)])
else:
grades2.sort()
median = (grades2[int(len(grades)/2-1)] +
grades2[int(len(grades)/2)])/2
print("Median score:", median)
unique=[]
seen=[]
for i in range(len(grades)):
if grades[i] not in unique:
unique.append(grades[i])
seen.append(1)
else:
position =
unique.index(grades[i])
seen[position] +=
1
mode = max(seen)
loc = seen.index(mode)
mode_list=[ ]
for i in range(len(seen)):
if seen[i] == mode:
mode_list +=
[unique[i]]
print("Mode score(s): ",end="")
for item in mode_list:
print(item,"",end="")
final_grades = filename + "_grades.txt"
grades_file = open(final_grades,'w')
for i in range(len(final)):
forfile = (final[i] + ','+
str(grades[i])+'\n')
grades_file.write(forfile)
grades_file.close()
print()
curveq = input("Would you like to apply a curve to the scores?
(y)es or (n)o?: ")
if curveq == "y":
newavg = float(input("Enter desired mean score:
"))
adding = newavg - avg
curved_grades = []
for i in range(len(grades)):
new_score = grades[i] +
adding
new_score =
format(new_score,'.2f')
curved_grades.append(new_score)
curved_file = filename +
"_grades_with_curve.txt"
curved_grade = open(curved_file,'w')
for i in range(len(final)):
forcurvedfile =
(final[i] + ',' + str(grades[i]) + ',' + str(curved_grades[i]) +
'\n')
curved_grade.write(forcurvedfile)
curved_grade.close()
print("Done! A new grade file has been written
(",curved_file,")",sep='')
Python 3.7.2 (Please comment on code and post screenshot of your source code. Thanks) class1: Part 1 You just finished administering the final exam for all of the students in the "Introduction t...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...
I need this in C++. This is all
one question.
Introduction Your eighth assignment will consist of two programs, which will involve the use of simple classes. The source code for these problems should be submitted using the naming conventions we specified in class. Please note that your computer programs should comply with the commenting and formatting rules as described in class. For example, there should be a header for the whole program that gives the author's name, class name,...
Can you comment notes along with the code so I can
follow along and understand what is being written?? Thanks in
advance!
Let's say we're in a directory and we want to rename every file ending in·c, to end in .C (i.e., capitalize the c'). Here's one way to do it: $ for i in *. c; b-basename "$1" .c'; mv "8b.c" do "8b.C". done Things get more complicated if you want more complex renaming. Say for example you just...
Question First, you need to design, code in Java, test and document a base class, Student. The Student class will have the following information, and all of these should be defined as Private: A. Title of the student (eg Mr, Miss, Ms, Mrs etc) B. A first name (given name) C. A last name (family name/surname) D. Student number (ID) – an integer number (of type long) E. A date of birth (in day/month/year format – three ints) - (Do NOT use the Date class from...
help with cse problem
Lab Exercise #11 Assignment Overview You will work with a partner on this exercise during your lab session. Two people should work at one computer. Occasionally switch the person who is typing. Talk to each other about what you are doing and why so that both of you understand each step Part A: Class Date . Download the files for this laboratory exercise, then run the Python shell and enter the following commands: >>>import date >>help(...
please help!! the first photo is to answeer the 4 questions! i
really just need help on question 11 and 12
QUESTION 9 Instructions A link to the data marathon is included in this section. You will use JMP to answer questions 9. 13. Each question includes the steps needed in JMP. In the following paragraph, you will find the steps to save graphs that you will need. marathon.txt Before loading the file into JMP, you will need to do...
Use of search structures! how can i make this program in python? Learning Objectives: You should consider and program an example of using search structures where you will evaluate search trees against hash tables. Given the three text files under containing the following: - A list of students (classes Student in the distributed code) - A list of marks obtained by the students (classes Exam results in the distributed code) - A list of topics (classes Subject in the distributed...
just the extra credit part please
Your customer needs an automated system to patrol the highways. The job of the system is to collect the following information on vehicles traveling down a certain stretch of highway: license plate number, current speed, and speed limit. A program is required to determine if a speeding ticket is needed for each set of data. Ticket will only be issued when number of miles per hours (mph) over the speed limit is at least...
in Python
Project 5: Payroll (Part 1) CS 1410 Background In this project you will implement a simple payroll system. For the first part of the assignment, you will submit a UML class diagram. The hypothetical company we are considering has 3 classifications of employees: 1. Hourly 2. Salaried 3. Commissioned There are 24 pay periods per year; 1/24th of a salary is paid each pay period to employees who receive a salary. We won't worry about taxes and other...
1 Overview The goal of this assignment is to help you understand caches better. You are required to write a cache simulator using the C programming language. The programs have to run on iLab machines. We are providing real program memory traces as input to your cache simulator. The format and structure of the memory traces are described below. We will not give you improperly formatted files. You can assume all your input files will be in proper format as...