shortstartup.com
No Result
View All Result
  • Home
  • Business
  • Investing
  • Economy
  • Crypto News
    • Ethereum News
    • Bitcoin News
    • Ripple News
    • Altcoin News
    • Blockchain News
    • Litecoin News
  • AI
  • Stock Market
  • Personal Finance
  • Markets
    • Market Research
    • Market Analysis
  • Startups
  • Insurance
  • More
    • Real Estate
    • Forex
    • Fintech
No Result
View All Result
shortstartup.com
No Result
View All Result
Home AI

Python File Handling Quiz – AICORR.COM

Python File Handling Quiz – AICORR.COM
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter


Welcome to the Python File Handling Quiz!

File handling is an essential concept in Python programming that allows reading, writing, and manipulating files on a computer. This quiz will test your understanding of file operations, modes, and best practices.

Try to answer the following 20 questions to evaluate your knowledge!

Table of Contents:

Python quizzes for beginners series

File Handling Quiz

Quiz Questions

1. Which function is used to open a file in Python?A. open()B. read()C. file()D. write()

Answer

A. open()

2. What mode is used to open a file for reading only?A. “r”B. “w”C. “a”D. “x”

Answer

A. “r”

3. What happens if you open a file in “w” mode and the file already exists?A. It appends to the fileB. It creates a new fileC. It deletes the file content and writes new contentD. It throws an error

Answer

C. It deletes the file content and writes new content

4. Which mode is used to append data to an existing file?A. “a”B. “w”C. “r”D. “x”

Answer

A. “a”

5. How do you properly close a file after opening it?A. close()B. end()C. stop()D. exit()

Answer

A. close()

6. Which statement is used to automatically close a file after working with it?A. with open()B. try-exceptC. auto_close()D. shut()

Answer

A. with open()

7. Which function is used to read the entire content of a file?A. read()B. readline()C. readlines()D. fetch()

Answer

A. read()

8. What does readline() do?

A. Reads a single line from the fileB. Reads the entire fileC. Writes to the fileD. Deletes the file

Answer

A. Reads a single line from the file

9. How do you write a list of strings to a file?A. write()B. writelines()C. write_all()D. append()

Answer

B. writelines()

10. What does “x” mode do when opening a file?A. Opens a file for exclusive creationB. Opens a file for readingC. Opens a file for appendingD. Opens a file and deletes its content

Answer

A. Opens a file for exclusive creation

11. What function is used to check if a file exists before opening it?A. exists()B. isfile()C. os.path.exists()D. file_check()

Answer

C. os.path.exists()

12. What will happen if you try to open a non-existent file in “r” mode?A. It creates the fileB. It throws an errorC. It writes an empty fileD. It appends to a new file

Answer

B. It throws an error

13. Which module is used to work with file paths?A. sysB. osC. pathD. file

Answer

B. os

14. How do you delete a file in Python?

A. delete()B. remove()C. erase()D. del()

Answer

B. remove()

15. What is the default mode when opening a file using open()?A. “w”B. “r”C. “a”D. “x”

Answer

B. “r”

16. What does “rb” mode mean?A. Read binaryB. Read bufferC. Read bytesD. Read binary and text

Answer

A. Read binary

17. What does seek() do in file handling?A. Moves the file pointer to a specific positionB. Closes the fileC. Deletes the fileD. Opens a new file

Answer

A. Moves the file pointer to a specific position

18. Which function is used to rename a file?A. rename()B. change_name()C. move()D. rename_file()

Answer

A. rename()

19. What is the use of tell() function?A. Returns the current position of the file pointerB. Reads a line from the fileC. Writes data to the fileD. Deletes file content

Answer

A. Returns the current position of the file pointer

20. How do you ensure that file changes are saved?A. By closing the fileB. By using save()C. By using apply()D. By using commit()

Answer

A. By closing the file

How did you do? 🎯

18-20 correct → 🏆 Excellent! You’re a Python functions pro!

14-17 correct → 👍 Great job! Keep practicing.

10-13 correct → 🙂 Good, but there’s room for improvement.

Below 10 → 🤔 No worries! Review the concepts and try again.


by AICorr Team

We are proud to offer our extensive knowledge to you, for free. The AICorr Team puts a lot of effort in researching, testing, and writing the content within the platform (aicorr.com). We hope that you learn and progress forward.



Source link

Tags: AICORR.COMfileHandlingPythonQuiz
Previous Post

Real-Time Enterprise Architecture In The Age Of AI

Next Post

Four Key EUC Trends From IGEL’s Now & Next 2025 Event

Next Post
Four Key EUC Trends From IGEL’s Now & Next 2025 Event

Four Key EUC Trends From IGEL’s Now & Next 2025 Event

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

shortstartup.com

Categories

  • AI
  • Altcoin News
  • Bitcoin News
  • Blockchain News
  • Business
  • Crypto News
  • Economy
  • Ethereum News
  • Fintech
  • Forex
  • Insurance
  • Investing
  • Litecoin News
  • Market Analysis
  • Market Research
  • Markets
  • Personal Finance
  • Real Estate
  • Ripple News
  • Startups
  • Stock Market
  • Uncategorized

Recent News

  • OPEC+ agrees on third oil supply surge despite Russia’s qualms
  • Is consolidation possible for me?
  • ElevenLabs Integrates Anthropic’s Claude Sonnet 4 for Advanced AI Voice Agents
  • Contact us
  • Cookie Privacy Policy
  • Disclaimer
  • DMCA
  • Home
  • Privacy Policy
  • Terms and Conditions

Copyright © 2024 Short Startup.
Short Startup is not responsible for the content of external sites.

No Result
View All Result
  • Home
  • Business
  • Investing
  • Economy
  • Crypto News
    • Ethereum News
    • Bitcoin News
    • Ripple News
    • Altcoin News
    • Blockchain News
    • Litecoin News
  • AI
  • Stock Market
  • Personal Finance
  • Markets
    • Market Research
    • Market Analysis
  • Startups
  • Insurance
  • More
    • Real Estate
    • Forex
    • Fintech

Copyright © 2024 Short Startup.
Short Startup is not responsible for the content of external sites.