0% found this document useful (0 votes)
22 views3 pages

Que&practical

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)
22 views3 pages

Que&practical

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/ 3

Files in Python

1. Explain the different types of files in Python, and discuss how they are used in various
applications. Provide examples of scenarios where text files and binary files would be
the appropriate choice.
2. Describe the process of opening and closing a file in Python. What modes can be used
to open a file, and how does the mode affect the operations that can be performed on
the file? Include code examples to illustrate your points.
3. Discuss the methods available in Python for working with text files containing strings.
4. How can you read, write, and append data to a text file? Provide code examples
demonstrating each operation.
5. What are binary files, and how do they differ from text files in terms of data storage
and manipulation?
6. Explain the process of reading from and writing to binary files in Python, with
relevant code examples.
7. How can you determine whether a file exists or not in Python? Discuss the different
methods.
8. explain how you would handle the situation where a file does not exist. Provide code
examples to support your explanation.

Regular Expressions

1. What are regular expressions (REs) in Python, and how are they used for pattern
matching?
2. Explain the significance of sequence characters, quantifiers, and special characters in
regular expressions. Provide examples to illustrate their usage.
3. Describe the process of using regular expressions in Python to work with files.
4. How can you search for, retrieve, and manipulate data in a file using regular
expressions? Include examples of how regular expressions can be applied to different
file types.
5. How can regular expressions be used to retrieve information from an HTML file?
Explain the process in detail, and provide code examples demonstrating how to
extract specific data from an HTML document using Python's regular expression
capabilities.

Data Frame

1. Discuss the role of data frames in data science using Python.


2. Explain how data frames can be created from various sources such as Excel
spreadsheets, CSV files, Python dictionaries, and lists of tuples. Provide examples for
each method of creation and explain the operations that can be performed on data
frames.
3. Explain the importance of data visualization in data science.
4. Discuss how different types of plots, such as bar graphs, histograms, pie charts, and
line graphs, can be used to represent data. Provide code examples to illustrate how
each type of plot is created using Python libraries.
5. Describe the process of creating a data frame in Python from an Excel spreadsheet
and a CSV file.
6. What are the advantages and challenges associated with each method? Provide code
examples that demonstrate the steps involved in creating and manipulating data
frames from these file types.
Practical List

1. Write a Python script that opens a text file named sample.txt, reads its contents, and
prints them to the console. Ensure the file is closed properly after reading.
2. Create a Python script that writes a list of strings to a text file, then reads the file and
prints each line to the console.
3. Write a Python function that takes a file path as input and checks if the file exists. If
the file exists, return True; otherwise, return False.
4. Create a Python script to open a binary file, write a series of bytes to it, and then read
the bytes back from the file. Demonstrate how to handle binary data in Python.
5. Write a Python script using regular expressions to search for and extract all email
addresses from a given text string.
6. Create a Python script that uses regular expressions to find sequences of digits in a
string, such as phone numbers or zip codes.
7. Write a Python script that uses regular expression quantifiers to match patterns like
repeated characters (e.g., "a+", "b{2,5}") and explain the patterns used.
8. Create a Python script that demonstrates the use of special characters in regular
expressions (e.g., \d, \w, .) to match various patterns in a given text.
9. Write a Python script to parse an HTML file and use regular expressions to extract all
URLs present in the HTML content.
10. Write a Python script using pandas to read data from an Excel spreadsheet and create
a DataFrame. Print the first few rows of the DataFrame.
11. Create a DataFrame from a CSV file using pandas. Perform a basic analysis by
printing the summary statistics and data types of the DataFrame.
12. Write a Python script to create a DataFrame from a dictionary, where the keys
represent column names and the values are lists of data. Display the DataFrame.
13. Create a DataFrame from a list of tuples, where each tuple represents a row of data.
Include column names and display the DataFrame.
14. Perform basic operations on a DataFrame, such as filtering rows based on a condition,
adding a new column, and grouping data by a specific column. Demonstrate each
operation with code examples.
15. Write a Python script using matplotlib to create a bar graph. The graph should
display the number of occurrences of different categories (e.g., products sold).
16. Create a histogram using matplotlib to show the distribution of a numerical dataset
(e.g., the ages of a group of people).
17. Write a Python script to generate a pie chart with matplotlib, representing the
proportion of different categories in a dataset (e.g., market share of different
companies).
18. Use matplotlib to create a line graph that shows changes in a dataset over time (e.g.,
monthly sales figures).

You might also like