Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python I am using this file Criteria.txt and it looks like this Homework,5,10,10 Quiz,3,20,20 Midterm,1,50,30 Final,1,100,40 I typed in this code to open and

In Python I am using this file Criteria.txt and it looks like this

Homework,5,10,10 Quiz,3,20,20 Midterm,1,50,30 Final,1,100,40

I typed in this code to open and manipulate the Criteria.txt file

>>> criteria=open('Criteria.txt','r')

>>> criteria_line=criteria.readline()

>>> criteria_myline=criteria_line.strip().split(',')

>>> for criteria_line in criteria:

... print (criteria_line),

... criteria_myline = criteria_line.strip().split(',')

... print ("Assignment Type: "+criteria_myline[0])

... print ("Number: "+ criteria_myline [1])

... print ("Points: "+ criteria_myline [2])

... print ("Weight: "+ criteria_myline [3])

... print ()

and the result was this

Quiz,3,20,20

(None,)

Assignment Type: Quiz

Number: 3

Points: 20

Weight: 20

Midterm,1,50,30

(None,)

Assignment Type: Midterm

Number: 1

Points: 50

Weight: 30

Final,1,100,40

(None,)

Assignment Type: Final

Number: 1

Points: 100

Weight: 40

This was all correct except Homework didn't show up. You can see in the Criteria.txt file hat Homework was also in the list. What is wrong with this code? Why did it leave Homework out? What is the right code?

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 And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago