Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

sorry for cramming it in but neeed help with file input and output , FormatChecker.py SubrnitRu Grades Reset || #This is a long one-our answer

image text in transcribedsorry for cramming it in but neeed help with file input and output

, FormatChecker.py SubrnitRu Grades Reset || #This is a long one-our answer is 28 lines of code, but That's because it's one of the Console output will be displayed here 3| # more authentic blems we've done so far. This is a real 4#problem you'll start to face if you want to start creati 5#useful programs. #One of the reasons that filetypes everyone how they are structured. A ".png" file, for example, sure the prograim that the file is actlly a pug. If these 6| #agrees 7 #always contains "PNG" in the first four characters to 9#standards were not set, it would be hard to write programs 10 #that know how 11 #Let's define a new filetype called ".cs1301" 12#In this file to open and read the file , every line should be structured like so: 14| #number assignment name grade total weight 15#In this file, each component will meet the following 16#description: 17 # -number: an integer-like value of the assignment number 18 # -assignment_name: a string, value of the assignment name 19 # -grade: an Integer-like value of a student's grade 20 #-total: an integer-like value of the total possible 21 # number of points 22 # -weight: a float-like value ranging from 0 to 1 23 # representing the percent of the student's grade this 24 # assignment isworth. All the weights should add up to 1 25 Each component should be separated with exactly one space 261#A good sample file is available to view as 27 #"sample.cs1301" 28 #lrite a function kalled format-checker that accepts a 29#filename and returns True if the file contents accurate! 39 #conform to the described format. Otherwise the function should return False. In other words, it should return T # . Eachline has five elements separated by spaces, Aip 34 #-The first, third, and fourth e 35#-The fifth element is a decimal number, AND 36 -All the fifth elements add to 1. You can make changes to test.cs1301 to test your function 38! #or test it with, sample.cs 130. Right now,.running it on 39 #sample.cs1301 should return True, and on test.cs1301 4e#should return False 41 #Hint 1: .split() will likely help separate each line into 42 #its c nts. mHint2: .splitQ,returns a list. so, if you were to do 43#something like say split-line- 44 #split-line[9] would give the first item, split-line [1] would 45#give the second iten, etc. #Hint 3: If you're having 46 #Parts. First check the file to see if it has the right 47#number of items per 48#the correct 49#1. Remembe line, then whether the items are of then whether the fifth elenents add to r, you know how to do each individual check 50 #(checking types, adding numbers, finding list lengths 51 #the hard part is knitting 52#solution this all together into one bigger 53 #8rite your function here! 54#Test your function below. With the original values of these 55#files, these should print True, then False: 57 orintfformat checker "samole 2.cs1301

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

More Books

Students also viewed these Databases questions

Question

Speak clearly and distinctly with moderate energy

Answered: 1 week ago