QUESTIONS AND CORRECT DETAILED ANSWERS
WITH RATIONALES
File I/O CORRECT ANSWER-<fileID> = open("<File Name>", "<designator>")
File I/O: what is the designator for? CORRECT ANSWER-
Designator is either "r" for reading or "w" for writing to a file
Part 1) Functions available after successfully opening a file CORRECT
ANSWER- to read a line from a file that is open for reading: readline( ).
*Syntax for readline( ) function:
<string variable> = <fileID>.readline()
This returns a string from where the file pointer is at the beginning of the call until a newline chara
cter is found.
Part 2) Functions available after successfully opening a file CORRECT
ANSWER- If we successfully open a file for writing,
then we can use the following function syntax to write a string to a file:
<fileID>.write(<string to write>)
%10.5f or %d to format specifiers to take care of the numbers
Modules CORRECT ANSWER-Common Modules:
import matplotlib.pyplot as plt
import numpy as np
import math