I am new to Python and wanted to read a file, which has even count of numbers, (say 20) numbers like
100
200
59
78
...
590
13
I want to read them and compute division result of val[11]/val[1], val[12]/val[2] etc. Would you please help me. Or any other language you could suggest where it would be fast. Thanks a lot.
Ok, this will get you just started with the basics, but you’ll have to figure out the logic of your math, the various index values, and order of operations to solve your problem.
This simply opens a file and displays its contents. The data is read as strings, and converted to floats so that you can do math with the numbers.
I strongly recommend you read a Python tutorial, or better yet work in a programming language you are
morefamiliar with.Contents of
data.txtThe rest is up to you. Please feel free to come back and ask for help when you get stuck with a specific problem.
Finally, since the data from the file ends up in a variable name
datawhich is a Python list, reading through these Python docs and this tutorial should be helpful in understanding this data structure.