Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON-JUPYTER NOTEBOOK Write a program that from a file with numbers (one number per line): reads the file calculates the maximum and minimum stores the

PYTHON-JUPYTER NOTEBOOK

Write a program that from a file with numbers (one number per line):

  • reads the file
  • calculates the maximum and minimum
  • stores the max and min in another file (the first line of the file with the max and the second line with the min)

This is what I have done so far, but it is not working:

file_a = open(input("File A:"),"r")

file_b=open(input("File B:"),'w')

num=[]

for line in file_a:

lines =[line.strip(' ') for line in file_a.readlines()]

print(lines)

for i in lines:

num.append(int(i))

newnum=[]

newnum.append(max(num))

newnum.append(min(num))

print(num)

file_b.write(str(newnum))

print(newnum)

print(min(num))

print(max(num))

file_a.close

file_b.close

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

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

3. You can gain power by making others feel important.

Answered: 1 week ago

Question

Write down the circumstances in which you led.

Answered: 1 week ago