What does the following python code do? f = open("sample.txt", "r") Choose all that apply.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

What does the following python code do?

f = open("sample.txt", "r")

Choose all that apply. 

 
Select 2 correct answer(s)

 

a.

If the file called sample.txt exists, it writes at the bottom of the file

b.

opens a file called sample.txt for appending

c.

reads the file called sample.txt starting from the top

d.

closes a file called sample.txt

e.

opens a file called sample.txt for reading

f.

if the file sample.txt does not exist, it creates the file and opens it

g.

if the file sample.txt exists, deletes everything in it

h.

writes "r" to the file called sample.txt 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT