100% Guaranteed Results


Machine Learning – How is input/output with files in python similar to C++? How is it different? Solved
$ 20.99
Category:

Description

5/5 – (1 vote)

Python uses the built in open() function to read/write the file (you need to specify using ‘r’ for reading and ‘w’ for writing), however C++ uses the fstream class which both reads and writes to/from the files. C++ also has ofstream which is for writing files and ifstream for reading files. They both take in parameters, the location of the file, and the file name. Then, python uses close() to stop reading in the file whereas in C++, you would use for example infile.close().
Create a file called num_to_add with pairs of numbers. You do not know how many number pairs are in your file.
Write a python program that reads each pair of numbers from the file and adds the numbers together.
Both numbers are printed along with the result to another file. For example, if you had the following data:
2 4
5 6
24 32
Your output file would look like:
2 4 6
5 6 11
24 32 56
Test your program with an input file of at least 20 number pairs.
Submit your answers to these questions to Blackboard. Upload your program to Bb along with your input and output files.

Reviews

There are no reviews yet.

Be the first to review “Machine Learning – How is input/output with files in python similar to C++? How is it different? Solved”

Your email address will not be published. Required fields are marked *

Related products