Question
basic python. loading data from text files and squaring them ==================== aaa.txt test a line 1 3,6,8,99,-4,0.6,8 0,9,7,5,7,9,5 2,2,2,2,2,2,5 7,5,1,2,12,8,0.9 ===================== bbb.txt test b line
basic python. loading data from text files and squaring them
====================
aaa.txt
test a line 1 3,6,8,99,-4,0.6,8 0,9,7,5,7,9,5 2,2,2,2,2,2,5 7,5,1,2,12,8,0.9 =====================
bbb.txt
test b line 1 1,2,3,4,5,6,7,8 55,0,90,09,1,2,3, 8,9,7,6,8,7,6 3,43,5,8,2,4,1
======================
def mi_func(P): f=open(P, 'r') first = f.readline() restlines= f.readlines() f.close() return first, restlines
afirst,arest = mi_func('aaa.txt') bfirst,brest = mi_func('bbb.txt')
print(arest) print(brest)
################## #convert a rest into a float here #convert b rest into a float here #################
p=[i**2 for i in arest] #square each element of a rest c=[i**2 for i in brest] #square each element of b rest print(p) print(c)
=============================================================
basic python. multiplying data from a text file text available at bottom to copy and paste seqwet Last Checkpoint: Last Wednesday at 7:15 PM (autosaved) a Notepad File Edit FormatView Help test a line 1 3,6,8,99,-4,0.6,8 0,9,7,5,7,9,5 2,2,2,2,2,2,5 7,5,1,2,12,8,0.9 View nsert Cel Kene WidgetsHelp afirst arest def mi_func(P): f-open(P, ' first - f.readlineO restlines- f.readlines(O f.close() return first, restlines bbb- Notepad File Edit Format View Help afirst,arest mifunc( aaa.txt') bfirst,brest - mi_func( bbb.txt') test,4,5,6,718 bfirst print (arest) print (brest) 55,0,90,09,1,2,3, 8,9,7,6,8,7,6 3,43,5,8,2,4,1 brest #convert a rest into a float here #convert b rest into a float here #square each element of a rest #square each element of b rest p=[i""2 for c-li."2 for print(p) print(c) i in arest] brest] i in please add code here ['3,6,8,99,-4,0.6,8 ', e,9,7,5,7,9,5 ', 2,2,2,2,2,2,5 , ['1,2,3,4,5,6,7,8 , 55,e,90,09,1,2,3, ', 8,9,7,6,8,7,6 ', 3,43,5,8,2,4,1 make any changes you TypeError Traceback (most recent call last) python-input-25-d83d49c3b17c> inStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started