Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Students will be able to: Content: Explain the purpose of write 0 functions Explain the difference between writing and appending to a file Process: Write

Students will be able to:
Content:
Explain the purpose of write 0 functions
Explain the difference between writing and appending to a file
Process:
Write code that opens, writes to and closes a file
Prior Knowledge
Python concepts from Activities 1-13
Enter and execute the following program:
def main() :
lastName = input ("Enter last name: ")
firstName = input ("Enter first name: ")
studentID = input ("Bnter ID: ")
infile hopen ("stadentinfo.txt",'a')
inFile.write ("Name: "+ firstName +""+ lastName)
inFil. write ("
StadentID: "+ studentID)
inFile. write ("??
")
infile. close ()
print("Done! Data is saved in file: studentInfo.txt")
main()
What output appears on the screen?
b. What does the program do?
c. Locate the file studentInfo.txt on your computer. The file is stored in the same folder as the program. What is stored in the file?
d. Change the argument 'a' to 'w' in the call to the open function. What is the purpose of the "w" in the following line of code?
infile = open ("studentInfo, txt","w")
e. Did you create the file: studentInfo.txt separately from the program code?
image text in transcribed

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions