My Report

Python File Test – 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What is the pickling?

2. Which is/are the basic I/O connections in file?

3. What will be the output of the following Python code?

import sys
sys.stdout.write(' Hello\n')
sys.stdout.write('Python\n')

4. What is unpickling?

5. Correct syntax of file.writelines() is?

6. Correct syntax of file.readlines() is?

7. What is the correct syntax of open() function?

8. What will be the output of the following Python code?

fo = open("foo.txt", "wb")
print "Name of the file: ", fo.name
fo.flush()
fo.close()

9. What will be the output of the following Python code? (If entered name is sanfoundry)

import sys
print 'Enter your name: ',
name = ''
while True:
   c = sys.stdin.read(1)
   if c == '\n':
      break
   name = name + c

print 'Your name is:', name

10. Which of the following mode will refer to binary data?


 

Start practicing “1000 MCQs on Python”, and once you are ready, you can take tests on all topics by attempting our “Python Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.