Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Python Institute Exam PCAP-31-03 Topic 4 Question 86 Discussion

Actual exam question for Python Institute's PCAP-31-03 exam
Question #: 86
Topic #: 4
[All PCAP-31-03 Questions]

What can you deduce from the following statement? (Select two answers)

str = open('file.txt', "rt")

Show Suggested Answer Hide Answer
Suggested Answer: A, D

Contribute your Thoughts:

Freida
2 hours ago
Haha, these answers are great. I'm just picturing some poor student frantically clicking through all the options, hoping they get it right. Good luck, my friend!
upvoted 0 times
...
Brice
11 days ago
This is a classic Python file handling question. I bet the exam writer is just trying to trip us up with that 'rt' mode. Who even uses that anymore? Everyone knows 'r' is the way to go!
upvoted 0 times
...
Doug
12 days ago
Hmm, I'm not sure about C. I've never seen a file get created automatically like that. And D, really? Why would you think you can't write to the file? That's just silly.
upvoted 0 times
...
Stephane
14 days ago
I think C is also correct. If the file doesn't exist, it will be created when you try to open it. But D is wrong - you can definitely write to the file using the 'str' variable.
upvoted 0 times
Mayra
5 days ago
C) if file.txt does not exist, it will be created
upvoted 0 times
...
Marjory
8 days ago
A) str is a string read in from the file named file.txt
upvoted 0 times
...
...
Gracia
16 days ago
I believe D) the opened file cannot be written with the use of the str variable is the correct answer
upvoted 0 times
...
Carmen
18 days ago
I disagree with A), I think B) a newlina character translation will be performed during the reads
upvoted 0 times
...
Julian
19 days ago
I agree with A), and also think C) if file.txt does not exist, it will be created
upvoted 0 times
...
Lavonne
25 days ago
I think A) str is a string read in from the file named file.txt
upvoted 0 times
...
Leah
26 days ago
A and B are correct. The 'rt' mode stands for 'read text', which means the file will be opened for reading and any newline characters will be translated.
upvoted 0 times
Allene
12 days ago
B) a newlina character translation will be performed during the reads
upvoted 0 times
...
Samira
13 days ago
A) str is a string read in from the file named file.txt
upvoted 0 times
...
...

Save Cancel