Unit 6: File Handling, Data Loading, and Visualization - Subjective Questions

CSR101 — Python Programming • Practice Questions with Detailed Answers

20 questions

1

Explain the process of reading a text file in Python. Discuss the use of open(), file modes, read(), readline(), and readlines() with suitable examples.

2

Describe the different file modes available in Python and explain when each mode should be used.

3

Explain how writing and appending data to files is performed in Python. Include examples and discuss the difference between write mode and append mode.

4

What is the with statement in Python file handling? Explain its advantages over manually opening and closing files.

5

Explain how Python interacts with the file system. Discuss paths, directories, file existence, and common functions from the os and pathlib modules.

6

What is binary data? Explain how binary files are read and written in Python, and distinguish binary mode from text mode.

7

Explain how command-line arguments can be used to specify input and output files in a Python program.

8

Explain the structure of a comma-separated values (CSV) file and describe how Python's csv module can be used to read and write CSV data.

9

Describe two methods of getting files from the Internet using Python. Explain how to download a file safely and store it locally.

10

Explain the steps involved in loading structured data into a Python program using Pandas. Include examples for CSV and Excel files.

11

Explain how selecting rows and columns from a Pandas DataFrame is performed. Compare loc and iloc with examples.

12

Explain filtering in Pandas. Show how to filter data using one condition, multiple conditions, missing values, and string matching.

13

Describe the purpose of data visualization and explain the basic steps for creating a visualization in Python.

14

Compare Matplotlib and Seaborn as Python visualization libraries. Discuss their main features, similarities, and differences.

15

Explain line plots in Matplotlib and Seaborn. State when a line plot is appropriate and describe how to customize it.

16

Explain bar charts and distinguish between vertical bar charts, horizontal bar charts, grouped bar charts, and stacked bar charts.

17

What is a histogram? Explain how it differs from a bar chart and discuss the roles of bins, frequency, and density.

18

Explain scatter plots and discuss how they can be used to study relationships between two numerical variables.

19

Design a complete Python workflow that downloads a CSV file, loads it into Pandas, filters the data, and visualizes the result using a chart.

20

Develop and explain a Python program that accepts an input CSV file and an output file name from the command line, selects records satisfying a condition, and writes the results to a new CSV file.