Question
please use python language
Task 2a: Reading a file with names Modify your function from task 1 to now read the names and student ids into your data stru
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

=======

print("Before Formatting: ")

with open('E:/namedMarks.txt') as f:

lines = f.read()

print(lines)

def printPretty():

nameOfFile = input("Enter the name of the marks file: ")

count = 0

with open(nameOfFile) as f:

lines = f.read()

lines = lines.replace('[','')

lines = lines.replace(']','')

lines = lines.replace("'",'')

data = lines.split(",")

for value in data:

print(value," ", end='')

count +=1

if count % 5 == 0:

print()

#After formatting

print("After Formatting: ")

printPretty()

Output:

=======

Before Formatting:

[['Rishad','23232323',78,54,68],['Haider','18493214',55,46,39]]

After Formatting:

Enter the name of the marks file: E:/namedMarks.txt

Rishad 23232323 78 54 68  

Haider 18493214 55 46 39  

File content:

=============

[['Rishad','23232323',78,54,68],['Haider','18493214',55,46,39]]

Screenshot of running code for indentation and understanding reference:

=======================================================================

File Edit View Insert Cell Kemel Widgets Help N Run C Code In [2]: print(Before Formatting:) with open(E:/namedMarks. txt

Add a comment
Know the answer?
Add Answer to:
please use python language Task 2a: Reading a file with names Modify your function from task...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider the below matrixA, which you can copy and paste directly into Matlab.

    Problem #1: Consider the below matrix A, which you can copy and paste directly into Matlab. The matrix contains 3 columns. The first column consists of Test #1 marks, the second column is Test # 2 marks, and the third column is final exam marks for a large linear algebra course. Each row represents a particular student.A = [36 45 75 81 59 73 77 73 73 65 72 78 65 55 83 73 57 78 84 31 60 83...

  • Find the indicated measure. The test scores of 40 students are listed below. Find P85.

    Find the indicated measure. The test scores of 40 students are listed below. Find P85. 30 35 43 44 47 48 54 55 56 57 59 62 63 65 66 68 69 69 71 72 72 73 74 76 77 77 78 79 80 81 81 82 83 85 89 92 93 94 97 98  1) 85  2) 87 3) 89 4) 34

  • Find the indicated measure. The test scores of 40 students are listed below. Find P85. 30...

    Find the indicated measure. The test scores of 40 students are listed below. Find P85. 30 35 43 44 47 48 54 55 56 57 59 62 63 65 66 68 69 69 71 72 72 73 74 76 77 77 78 79 80 81 81 82 83 85 89 92 93 94 97 98 1) 85 2) 87 3) 89 4) 34

  • 1. Forecast demand for Year 4. a. Explain what technique you utilized to forecast your demand....

    1. Forecast demand for Year 4. a. Explain what technique you utilized to forecast your demand. b. Explain why you chose this technique over others. Year 3 Year 1 Year 2 Actual Actual Actual Forecast Forecast Forecast Demand Demand Demand Week 1 52 57 63 55 66 77 Week 2 49 58 68 69 75 65 Week 3 47 50 58 65 80 74 Week 4 60 53 58 55 78 67 57 Week 5 49 57 64 76 77...

  • Quality of Marriage             Quality of the Parent–Child Relationship 76                   

    Quality of Marriage             Quality of the Parent–Child Relationship 76                                                                    43 81                                                                    33 78                                                                    23 76                                                                    34 76                                                                    31 78                                                                    51 76                                                                    56 78                                                                    43 98                                                                    44 88                                                                    45 76                                                                    32 66                                                                    33 44                                                                    28 67                                                                    39 65                                                                    31 59                                                                    38 87                                                                    21 77                                                                    27 79                                                                    43 85                                                                    46 68                                                                    41 76                                                                    41 77                                                                    48 98                                                                    56 98                                                                    56 99                                                                   55 98                                                                    45 87                                                                   68 67                                                                   54 78                                                                   33 Using the 10 steps for testing hypotheses (list all the ten steps and provide the answer under each), determine if the null hypothesis can be rejected or fail to be rejected.   •1. State the null hypothesis (H0) •2. State the research or alternate...

  • Write a python nested for loop that prints out the following pattern 100 99 98 97...

    Write a python nested for loop that prints out the following pattern 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33...

  • RANGES FREQUENCY RELATIVE FREQUENCY CUMULATIVE REL. FREQ. 1 - 10 11 - 20 21 - 30 31 - 40...

    RANGES FREQUENCY RELATIVE FREQUENCY CUMULATIVE REL. FREQ. 1 - 10 11 - 20 21 - 30 31 - 40 41 - 50 51 - 60 61 - 70 71 - 80 81 - 90 91 - 100 '= 100 DATA VALUES?? SO, WHAT DOES A FREQUENCY TABLE TELL US? If you wrote each of the above data values on a ping pong ball,, put them in a jar and blindly pulled one out: What is the probability that this ball...

  • The ages at death for a sample of 40 residents who died in certain city are...

    The ages at death for a sample of 40 residents who died in certain city are listed below. 25 35 43 65 47 77 54 94 81 57 72 62 83 44 66 92 78 69 71 82 59 73 63 76 89 48 69 79 56 98 80 82 74 85 77 68 93 55 97 72 The inter-quartile range, IQR, for the given data is 23 24 23.5 O 24.5

  • Question 1 15 pts Test scores for a class of 40 students are listed below: 25...

    Question 1 15 pts Test scores for a class of 40 students are listed below: 25 35 43 44 47 48 54 55 56 57 59 62 63 65 66 68 69 69 71 72 72 73 74 76 77 77 78 79 80 81 81 82 83 85 89 92 93 94 97 98 a) The mean of the sample data is b) The median of the sample data is c) The standard deviation of the sample data is...

  • NUMBER OF PEOPLE 10.2 10.0 10.1 8.5 10.2 8.2 8 Source: United States Census. 11. In...

    NUMBER OF PEOPLE 10.2 10.0 10.1 8.5 10.2 8.2 8 Source: United States Census. 11. In the Sanitary District of Chicago, operating engineers are hired on of a competitive civil-service examination. In 1966, there were 223 appl for 15 jobs. The exam was held on March 12; the test scores are s arranged in increasing order. The height of each bar in the histogram next page) shows the number of people with the correspondin examiners were charged with rigging the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT