[go: up one dir, main page]

0% found this document useful (0 votes)
3 views2 pages

Assignment 1

This assignment consists of 15 tasks aimed at practicing fundamental Python concepts, data analysis, and visualization techniques using NumPy, Pandas, and Matplotlib. Tasks include generating Fibonacci numbers, creating and manipulating arrays and DataFrames, handling files, and visualizing data through various plots. Each question focuses on different aspects of Python programming and data handling skills.

Uploaded by

muskan1491625
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)
3 views2 pages

Assignment 1

This assignment consists of 15 tasks aimed at practicing fundamental Python concepts, data analysis, and visualization techniques using NumPy, Pandas, and Matplotlib. Tasks include generating Fibonacci numbers, creating and manipulating arrays and DataFrames, handling files, and visualizing data through various plots. Each question focuses on different aspects of Python programming and data handling skills.

Uploaded by

muskan1491625
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

ASSIGNMENT-1

Objective : This assignment consists of various tasks to help you practice fundamental
Python concepts, data analysis, and visualization techniques using NumPy, Pandas, and
Matplotlib. Please solve each of the following problems:

Question 1: Control Flow and Loops


Write a Python function to generate the first N Fibonacci numbers. Test the
function with N = 10.

Question 2: List and Dictionary Comprehension


Create a list of squares of numbers from 1 to 20 using list comprehension. Then, create
a dictionary where the keys are numbers from 1 to 10, and the values are their cubes
using dictionary comprehension.

Question 3: File Handling


Write a Python script to create a CSV file named data.csv with three columns: Name,
Age, and Score. Write at least five rows of data, then read the file and print the rows
where the score is above 75.

Question 4: Array Operations


Create a 1D NumPy array of 25 random integers between 10 and 100. Perform the
following:

• Find the maximum, minimum, and their indices.

• Replace all odd numbers in the array with -1.

Question 5: Matrix Manipulation


Create a 5x5 matrix with random numbers. Perform the following:

• Extract the diagonal elements.

• Calculate the sum of all elements above the main diagonal.

Question 6: Statistical Functions


Generate a 3D NumPy array of shape (3, 4, 5) with random floats. Perform the following:

• Calculate the mean, median, and standard deviation of the entire array.

• Normalize the array by subtracting the mean and dividing by the standard
deviation.

Question 7: Broadcasting and Indexing


Create two 2D arrays of shape (4, 4) and (4, 1). Use broadcasting to add these arrays
element-wise and display the result.
Question 8: DataFrame Creation and Basic Operations
Create a Pandas DataFrame with three columns: Product, Price, and Quantity. Populate
it with at least 8 rows. Perform the following:

• Calculate the total value for each product (Price × Quantity).

• Add a new column for the total value and sort the DataFrame by this column.

Question 9: Data Filtering


Load the Titanic dataset from the Kaggle Titanic dataset or any publicly available
source. Filter and display rows where:

• The passenger age is below 18.

• The passenger is female and survived.

Question10: Groupby Operations


Load the Iris dataset from Seaborn library or any other source like Kaggle, etc. Group the
data by species and calculate the mean of petal length and sepal width for each group.

Question 11: Handling Missing Values


Create a Pandas DataFrame with random data and intentionally introduce NaN values.
Replace the NaN values with the column mean and display the updated DataFrame.

Question 12: Merging DataFrames


Create two DataFrames: one with columns ID and Name, and another with columns ID
and Score. Merge the two DataFrames on the ID column and display the resulting
DataFrame.

Question 13: Line Plot


Generate a random dataset representing the monthly revenue of a company. Plot a line
graph to show the trend, and customize it with:

• A title, labeled axes, and a legend.

Question 14: Bar Plot


Create a dataset representing the sales of five products in two different regions. Use a
grouped bar chart to display the comparison between the regions for each product.
Ensure that the plot is customized with:

• A title, labeled axes, and a legend.

Question 15: Scatter Plot


Load the Iris dataset from Seaborn library or any other source like Kaggle, etc. Create a
scatter plot comparing any two features of the flowers (e.g., petal length vs petal width,
sepal length vs sepal width). Customize the plot to use different colors for each species
and add labels and a title.

You might also like