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

Python unit-4 answers

Uploaded by

Jitesh Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python unit-4 answers

Uploaded by

Jitesh Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1) What is aggregation functions? Explain any 5. __Same answer for Q6.

Aggregation functions are used to summarize or combine multiple values into a single result. They
are often used in databases, spreadsheets, and data analysis to calculate important statistics from
large sets of data. Here are five common aggregation functions explained in simple terms:

1. SUM: Adds up all the numbers in a set of data. For example, SUM([100, 200, 150, 300]) = 750

2. AVERAGE: Calculates the average (or mean) of a set of numbers. For example,
AVERAGE([10, 20, 30, 40]) = (10 + 20 + 30 + 40) / 4 = 25

3. COUNT: Counts how many items or values are in a data set. For example, COUNT(["Alice",
"Bob", "Charlie"]) = 3

4. MIN: Finds the smallest number in a set of data. For example, MIN([10, 20, 5, 30]) = 5

5. MAX: Finds the largest number in a set of data. For example, MAX([15, 42, 27, 38]) = 42

These functions help summarize large amounts of data into easy-to-understand values.

2) Explain advantages of NumPy array over python list.

Advantages of NumPy Array over Python List:

1. Faster Computations:
NumPy arrays are much faster than Python lists for numerical operations. This is because
NumPy is implemented in C and optimizes operations for large datasets, making it more
efficient for math-heavy tasks.

2. Memory Efficiency:
NumPy arrays take up less memory than Python lists. Lists in Python store data as objects,
whereas NumPy arrays store data in a more compact format, reducing memory usage,
especially with large amounts of data.

3. Element-wise Operations:
With NumPy, you can perform operations (like addition, multiplication) directly on entire
arrays, without needing loops. For example, adding two NumPy arrays together is much
simpler than doing the same with Python lists.

4. Support for Multi-dimensional Arrays:


NumPy allows you to work with multi-dimensional arrays (like matrices), whereas Python
lists are mainly one-dimensional or require extra work to handle multiple dimensions.

5. Built-in Functions:
NumPy provides many powerful functions for mathematical, statistical, and linear algebra
operations, like finding the mean, standard deviation, and matrix multiplication, which are
not available in basic Python lists.

In short, NumPy arrays are more efficient, faster, and offer more functionality than Python lists,
especially when working with numerical and scientific data.
5) List down the advantages and disadvantages of data visualization

Advantages of Data Visualization:

1. Simplifies Complex Data: Data visualization helps to make complex data easier to
understand by presenting it in the form of charts, graphs, and other visuals.

2. Quick Insights: It allows viewers to quickly grasp key trends, patterns, and outliers without
having to dig through raw data.

3. Better Decision Making: Visual representations of data help decision-makers identify


problems or opportunities quickly and make more informed decisions.

4. Improves Retention: People tend to remember information better when it is visualized


rather than when it’s presented as raw numbers or text.

5. Effective Communication: It helps communicate findings to a wider audience, even those


who might not be familiar with the data, making the message clearer and more engaging.

Disadvantages of Data Visualization:

1. Misleading Representations: If not done correctly, visualizations can mislead viewers by


distorting data, such as using inappropriate scales or cherry-picking data points.

2. Over-simplification: Sometimes, visuals can oversimplify complex data, leading to loss of


important details or nuances.

3. Requires Skills: Creating accurate and effective visualizations requires skills and knowledge of
both the data and the right tools, which can be a challenge.

4. Time-Consuming: Designing high-quality and meaningful visualizations can be time-


consuming, especially for large datasets.

5. Dependency on Technology: Data visualizations require the use of software tools, which may
not be accessible to everyone, especially in low-resource environments.

These points provide a balanced view of the benefits and limitations of data visualization, helping to
understand its role in data analysis and communication.
7 ) What is data visualization and why it is important. __ Same answer for Q10

Data visualization is the process of representing data and information in visual formats like charts,
graphs, or maps. It helps people understand complex data easily by turning numbers into pictures.

It is important because:

1. Simplifies Complex Data: Data visualization helps to make complex data easier to
understand by presenting it in the form of charts, graphs, and other visuals.

2. Quick Insights: It allows viewers to quickly grasp key trends, patterns, and outliers without
having to dig through raw data.

3. Better Decision Making: Visual representations of data help decision-makers identify


problems or opportunities quickly and make more informed decisions.

4. Improves Retention: People tend to remember information better when it is visualized


rather than when it’s presented as raw numbers or text.

5. Effective Communication: It helps communicate findings to a wider audience, even those


who might not be familiar with the data, making the message clearer and more engaging.
9) Explain dimensions of NumPy array with suitable example

In NumPy, a dimension refers to the level or depth of an array. It is like the number of axes or
directions in which the array can grow. Here are the dimensions explained with examples:

1. 1D Array (1 Dimension): A simple list of numbers.

Example: `[1, 2, 3]`

This has only one dimension (rows).

2. 2D Array (2 Dimensions): A table or matrix with rows and columns.

Example: `[[1, 2, 3], [4, 5, 6]]`

This has two dimensions: rows and columns.

3. 3D Array (3 Dimensions): A collection of 2D arrays, like a cube.

Example: `[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]`

This has three dimensions: layers, rows, and columns.

In short, dimensions in NumPy arrays define their structure, like a line (1D), a table (2D), or a cube
(3D).
11) Explain the following with the help of the example :

1.numpy.sum

2.numpy.argmax

3.numpy.argmin

4.numpy.percentile

5.numpy.prod
6.numpy.var

7.numpy.std

These functions are commonly used in data analysis and scientific computing with NumPy.
12) Explain the difference between histogram and bar chart

You might also like