0% found this document useful (0 votes)
4 views

Python File Handling Basics _ Quizizz

Uploaded by

esraayaksiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Python File Handling Basics _ Quizizz

Uploaded by

esraayaksiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

çalışma sayfaları İsim

Python File Handling Basics


Sınıf
Toplam questions: 10
Çalışma sayfası süresi: 5dakika
Tarih
Eğitmen adı: Doodle with me

1. How can you read from a file in Python?

a) file.open('file.txt', 'read') b) read('file.txt')

c) open('file.txt', 'r').read() d) open('file.txt', 'w').read()

2. What is the method to write to a file in Python?

a) Use the 'write' function with 'w' mode, 'open' method b) Use the 'open' function with 'r' mode, 'write' method
to open the file, and 'close' method to close the file. to write content, and 'close' method to close the file.

c) Use the 'open' function with 'w' mode, 'write' method d) Use the 'read' function with 'w' mode, 'write' method
to write content, and 'close' method to close the file. to write content, and 'close' method to close the file.

3. Why is it important to close a file after operations in Python?

a) To increase system performance b) To save memory space

c) To release system resources and ensure data is d) To speed up file operations


written properly.

4. How can you handle errors in file operations in Python?

a) Handle errors by restarting the Python interpreter. b) Ignore errors that occur during file operations.

c) Use try-except blocks to handle specific errors that d) Use if-else statements to handle errors in file
may occur during file operations. operations.

5. What is the significance of working with file paths in Python file handling?

a) File paths in Python file handling are essential for b) File paths in Python file handling are only used for
specifying the location of files on the system, decorative purposes.
enabling reading, writing, and managing data
effectively.

c) Working with file paths in Python file handling has d) Python file handling does not support file paths.
no impact on data management.

https://quizizz.com/print/quiz/66a35bc1e531479bd561c91f 1/2
19.01.2025 20:42 Python File Handling Basics | Quizizz

6. Explain the process of reading a file line by line in Python.

a) open('file.txt', 'r').readlines(): b) with open('file.txt', 'r') as file: for line in file: print(line)

c) for line in file.readlines(): d) file.read():

7. Discuss the different modes used for opening a file in Python.

a) Different modes used for opening a file in Python b) y


are 'r', 'w', 'a', 'r+', 'w+', and 'a+'.

c) x d) z

8. What are some common exceptions that can occur during file operations in Python?

a) SyntaxError b) IndexError

c) FileNotFoundError, PermissionError, IOError, d) ValueError


OSError

9. How can you check if a file exists at a specified path in Python?

a) Check the file using 'file_check' module b) Use the 'check_file' function

c) import os file_path = 'path/to/file' if d) Verify file existence with 'file_exists' method


os.path.exists(file_path): print('File exists') else:
print('File does not exist')

10. Explain the concept of file permissions in Python file handling.

a) File permissions determine the color scheme of the b) File permissions refer to the number of lines a file
file in Python file handling. can contain in Python file handling.

c) File permissions are used to control the font size in d) File permissions in Python file handling refer to the
Python file handling. access rights given to users or groups to read,
write, or execute a file. These permissions are
represented using a 3-digit octal number where
each digit corresponds to the permission type for
the owner, group, and others.

https://quizizz.com/print/quiz/66a35bc1e531479bd561c91f 2/2

You might also like