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
9 days 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
20 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
21 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
Miesha
3 days ago
A) str is a string read in from the file named file.txt
upvoted 0 times
...
...
Stephane
23 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
14 days ago
C) if file.txt does not exist, it will be created
upvoted 0 times
...
Marjory
17 days ago
A) str is a string read in from the file named file.txt
upvoted 0 times
...
...
Gracia
25 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
27 days ago
I disagree with A), I think B) a newlina character translation will be performed during the reads
upvoted 0 times
...
Julian
28 days ago
I agree with A), and also think C) if file.txt does not exist, it will be created
upvoted 0 times
...
Lavonne
1 months ago
I think A) str is a string read in from the file named file.txt
upvoted 0 times
...
Leah
1 months 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
21 days ago
B) a newlina character translation will be performed during the reads
upvoted 0 times
...
Samira
22 days ago
A) str is a string read in from the file named file.txt
upvoted 0 times
...
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77