Python Exercise Lists

Python Numpy Data Analysis Exercises

1. Write a Python Numpy program to generate 3x3 matrix and display the maximum and minimum of y axis .

The output is:

Expected Answer:
3x3 matrix:
[[0 1 2]
[3 4 5]
[6 7 8]]

Maximum value along the y axis: [2 5 8]
Minimum value along the y axis: [0 3 6]

Click for the answer



2. Write a Python Numpy program to generate 3x3 array and display the maximum and minimum of value in the 3x3 array.

The output is:

Expected Answer:
3x3 array:
[[0 1 2]
[3 4 5]
[6 7 8]]

Maximum value of the array:
8
Minimum value of the array:
0

Click for the answer



3. Write a Python Numpy program to generate 3x3 array and calculate to find out the difference between maximum and minimum value in x axis.

The output is:

Expected Answer:
3x3 array:
[[0 1 2]
[3 4 5]
[6 7 8]]

Difference between the maximum and the minimum values of the 3x3 array:
[2 2 2]

Click for the answer



4. Write a Python Numpy program to generate 4x3 array and find out the median of the array.

The output is:

Expected Answer:
Initial 3x4 array:
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]

Median of 3x4 array: 5.5

Click for the answer



5. Write a Python Numpy program to calculate the 65th percentile for all elements in the 3x4 array along the first axis (x-axis).

The output is:

Expected Answer:
Initial 3x4 array:
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]

65th percentile for all elements of the 3x4 array along the first axis:
[5.2 6.2 7.2 8.2]

Click for the answer



6. Write a Python Numpy program to calculate weight average of the given array in the following output.

The output is:

Expected Answer:
Initial array: [1 2 3 4 5]
Weights:    [2 3 4 5 6]

Weighted average of the array: 3.5

Click for the answer



7. Write a Python Numpy program to calculate the mean, standard deviation and variance of the given array in the following output.

The output is:

Expected Answer:
Initial array: [1 2 3 4 5]
Mean: 3.0
Standard deviation: 1.707825127659933
Variance: 2.9166666666666665

Click for the answer



8. Write a Python Numpy program to calculate cross-correlation of the two given array in the following output.

The output is:

Expected Answer:
Initial array1:
[1 2 3 4]

Initial array2:
[6 7 8 9]

Cross-correlation of the arrays:
[[1.66666667 1.66666667]
[1.66666667 1.66666667]]

Click for the answer



                               


More Exercises:

Python String Exercises
Python List Exercises
Python Library Exercises
Python Sets Exercises
Python Array Exercises
Python Condition Statement Exercises
Python Lambda Exercises
Python Function Exercises
Python File Input Output Exercises
Python Tkinter Exercises


More Numpy Exercises:

Numpy String Exercises
Numpy Integer Exercises
Numpy Array Exercises
Numpy Data Analysis Exercises
Numpy Data Sorting Exercises


More Pandas Exercises:

Pandas Series Exercises


More Tutorials:

Python Installation - Linux (Ubuntu)
Python Installation - Mac OS
Integrated Development Environment - IDE
Python - Basic Variables
Python - Sequence Introduction
Python - Output Formatting
Python - Escape Character
Python - Type Conversion
Python - Numbers
Python – Arithmetic Operators
Python – Assignment Operators
Python – Comparison Operators
Python – Logical Operators
Python – Precedence and Associativity Operators
Python – Bytes Type and Usage
Python – Long & Raw Strings
Python – Concatenate Function
Python – Slice Function
Python – Length and Split Function
Python – Join and Count Function
Python – Find Function
Python – Index Function
Python – Alignment Function
Python – Startswith and Endswith Function
Python – String Case Conversion
Python – Remove Specified Character
Python – Encode and Decode Function
Python – dir and help Function
Python – Input Output Introduction
Python – Basic Operation
Python – Open Function
Python – Read Function
Python – Readline Function
Python – Write Function
Python – Close Function
Python – Seek and Tell Function
Python – Pickle Module
Python - File Input Module and Linecache Module
Python - Pathlib Module
Python - Pathlib Module
Python - os.path Module
Python - fnmatch Module
Python - Tuple Introduction
Python - List Introduction
Python - List Add Element
Python - List Delete Element
Python - List Modification Element
Python - List Find Element
Python - Dictionary Introduction
Python - Dictionary Basic Operation
Python - Dictionary Method Guide
Python - Set Collection
Python - Set Basic Operation
Python - Set Basic Method
Python - Frozenset Method
Python - If Condition I
Python - If Condition II
Python - While loop
Python - For loop
Python - Pass Statement
Python - Break Statement
Python - Zip Reverse Function
Python - Function Introduction
Python - Positional Parameters
Python - Key Arguments
Python - None and Return
Python - Variable Scope
Python - Local Function
Python - Closure Method
Python - Lamdba Expression