Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the txt file given. Working with Python in Jupyter, on PC. Thank you. Exercise 1 Write code that reads the file line-by-line numbers.txt,

image text in transcribedimage text in transcribed

This is the txt file given. Working with Python in Jupyter, on PC. Thank you.

Exercise 1 Write code that reads the file line-by-line numbers.txt, then does the following: Sum all the numbers in numbers.txt, then prints the numbers to the screen. Next, append the string "SUM: K", where k is the calculated sum, to the end of numbers.txt as a new line. Finally, print the entire file to make sure you appended to the file correctly. The absolute path for the file is "..umbers.txt" Important Python concepts: for, open ('a' and 'r'), write().print() In [ ]: # If you mess up the file and need to try again, run this cell with open('numbers.txt', 'w') as in_file: in_file.write('42 18 22 18') with open("numbers.txt") as iFile: print(iFile.read() In [ ]: # Write code to read file and calculate sum here In [ ]: # Print sum here In [ ]: # Write code to append to file here Run the line below to check your work In [ ]: with open("numbers.txt") as iFile: print(iFile.read() numbers.txt - Notepad File Edit Format View Help 142 18 22 18 SUM: 100.0

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

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

Students also viewed these Databases questions

Question

Explain budgetary Control

Answered: 1 week ago

Question

Solve the integral:

Answered: 1 week ago

Question

What is meant by Non-programmed decision?

Answered: 1 week ago

Question

What are the different techniques used in decision making?

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago