1 answer

Please use python language Task 2a: Reading a file with names Modify your function from task...

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
Task 2a: Reading a file with names Modify your function from task 1 to now read the names and student ids into your data structure. Remember that the names and student IDs will need to be left as strings. For example: Enter the name of the marks file: named Marks.txt [['Rishaad', '22223333', 25, 65, 48], ['Leslie', '23232323', 78, 54, 68], ['Haidar', '18493214', 55, 46, 39], ['Sel', '50015542', 70, 81, 75], ['Istiaque', '35503401', 100, 98, 90], ['Morgan', '25678890', 65, 89, 43], ['Mehran', '34545742', 65, 78, 87], ['Gavin', '04587864', 87, 56, 76], ['Shannon', '44678646', 65, 76,65]] Task 2b: PrintPretty Use the function printPretty you created in Week 3 to print the output in a more readable format. For example: Enter the name of the marks file: named Marks.txt Rishaad 22223333 25 65 48 Leslie 23232323 78 54 68 Haidar 18493214 55 46 39 Sel 50015542 70 81 75 Istiaque 35503401 100 98 90 Morgan 25678890 65 89 43 Mehran 34545742 65 78 87 Gavin 04587864 87 56 76 Shannon 44678646 65 76 65

Answers

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

.

Similar Solved Questions

1 answer
L Moving to another question will save this response. Question 13 Determine the x- and y-intercepts...
L Moving to another question will save this response. Question 13 Determine the x- and y-intercepts for the following function. h(x) = -5x+3 Xintercept: (3, 0); yintercept (0.3) X- and y-intercept: (0,0) x-intercept: }; y-intercept:(0,3) x-intercept: (0.5) y-intercept: (3, 0) L Moving to another que...
1 answer
A fluid having a viscosity u 9.35 x 104 lbf-s/ft is contained between two parallel plates,...
A fluid having a viscosity u 9.35 x 104 lbf-s/ft is contained between two parallel plates, each of which has a cross section of 200 in2. The bottom plate is fixed whereas the top plate moves at a constant velocity of 4 ft/s when a shearing force is applied. The separation distance between the plates...
1 answer
5. A bar of length 2.0 m and weight 80.0 N is sup- ported 0.60 m...
5. A bar of length 2.0 m and weight 80.0 N is sup- ported 0.60 m from the left end by a cable and at the right end by a support which exerts an upward force). Find the tension in the cable and the force of the support....
1 answer
Write two pages analyzing the followings constitutionallity: Ohio passes a statute requiring that any woman seeking...
Write two pages analyzing the followings constitutionallity: Ohio passes a statute requiring that any woman seeking an abortion must have a pre-abortion appointment with a counselor that provides detailed information about adoption and wait at least 5 days after her initial appointment before having...
1 answer
Ashley deposits $500 into an account that earns 2% interest compounded 3 times per year. How much money will Ashley have in her account after 4 years?
Ashley deposits $500 into an account that earns 2% interest compounded 3 times per year. How much money will Ashley have in her account after 4 years?...
1 answer
Vaughn Company follows the practice of pricing its inventory at the lower-of-cost-or-market, on an individual-item basis....
Vaughn Company follows the practice of pricing its inventory at the lower-of-cost-or-market, on an individual-item basis. Estimated Selling Price Cost of Completion and Disposal Item No. Quantity Cost per Unit Cost to Replace Normal Profit 1320 2,000 $3.68 $3.45 $5.18 $0.40 $1.44 1333 1,700 3.11 2.6...
1 answer
How could you paraphrase or rewrite this one ? Opioid overprescribing is a key contributor to...
How could you paraphrase or rewrite this one ? Opioid overprescribing is a key contributor to the current crisis. Changing how ethics is taught in connection with opioid prescribing is one area for improvement. In US medical schools, current training in ethics and opioid prescribing is variable, ...
1 answer
1. A researcher selected a random sample of 268 former students, 110 of whom were student-athletes,...
1. A researcher selected a random sample of 268 former students, 110 of whom were student-athletes, from a list of graduates of a large university. A total of 17% of the sample of student-athletes had earned graduate degrees, compared to 14% of the non-student-athletes. We want to know: Is this diff...
1 answer
2. Decode (get base 10 value of) the following bit patterns using the floating-point format described...
2. Decode (get base 10 value of) the following bit patterns using the floating-point format described below. Show your work and box the final answer. a. 01011010 b. 11001000 00101100 d. 10111001 C. -Bit positions Mantissa Exponent Sign bit...
1 answer
What are the 'three parts" of the Revolutionary War?
I know about of the battle of Trenton but i'm not really sure where it fits in the picture...
1 answer
A proton has a kinetic energy of 7.5 MeV. What is the speed of an alpha...
A proton has a kinetic energy of 7.5 MeV. What is the speed of an alpha particle that has the same DeBroglie wavelength as the proton? The mass of the alpha particle is 6.65E-27 kg. 9517 m/s 9.53E6 m/s 1833 m/s 2.38E13 m/s 0.747 m/s...
1 answer
Hearing aids can be tuned to filter out or amplify either high- or low-frequency sounds, depending...
Hearing aids can be tuned to filter out or amplify either high- or low-frequency sounds, depending on the frequency range in which a user has suffered hearing loss. If, for instance, a user needed to amplify low-frequency sounds and the hearing aid had a capacitance of 2.0 μF what inductance L sh...
1 answer
Let C be square matrix. i) Check if S = C + CT is symmetric ii)...
Let C be square matrix. i) Check if S = C + CT is symmetric ii) Check if N + C - CTis skew symmetric iii) Prove that every square matrix can be written as a sum of skew symmetric matrix and symmetric matrix...
1 answer
Q.2: Cesium has a melting point of 302 K and a boiling point of 944 K....
Q.2: Cesium has a melting point of 302 K and a boiling point of 944 K. What is the physical state of cesium when the temperature of the surroundings is 68 F? Please explain your approach in detail and show stepwise...
1 answer
The capital structure weights used in computing the weighted average cost of capital are: Group of...
The capital structure weights used in computing the weighted average cost of capital are: Group of answer choices preferably based on the target capital structure of the firm preferably computed using the book value of debt and the shareholder’s equity constant over time preferably based on th...
1 answer
A study shows that the coefficient of the cross price elasticity of Coke and Sprite is...
A study shows that the coefficient of the cross price elasticity of Coke and Sprite is positive. This information indicates that Coke and Sprite are: a. Inferior goods b. Substitute goods c. Complementary goods d. Independent goods...
1 answer
Monroe Group is preparing its cash collections budget. Budgeted sales are $150,000 in July, $175,000 in...
Monroe Group is preparing its cash collections budget. Budgeted sales are $150,000 in July, $175,000 in August, and $200,000 in September. Fifty percent of sales are cash sales; the remainder is on account. Sales on account are expected to be collected 30% in the month of sale, 60% in the month foll...