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

Python Programming Questions

Uploaded by

Punit Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python Programming Questions

Uploaded by

Punit Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

10 Programming Questions in Python

1. Write a Python program to create an array of 20 evenly spaced values between 1 and 10
using NumPy. Also, demonstrate how to generate an array of 10 random values between 0
and 1.

2. Write a program to demonstrate the use of advanced indexing in NumPy. Select specific
elements from a 2D array using index arrays and explain the results.

3. Implement a Python program that demonstrates broadcasting by performing element-


wise addition between two arrays of different shapes. Explain how broadcasting rules apply
in your example.

4. Write a Python program that iterates over a multi-dimensional NumPy array and prints
each element along with its index. Use at least two different iteration methods.

5. Write a Python program to reshape a 1D array into a 3x4 2D array. Also, demonstrate
how to concatenate two arrays along different axes.

6. Write a Python program that uses binary operators on two NumPy arrays. Perform AND,
OR, and XOR operations and display the output for each operation.

7. Implement a Python program to manipulate string arrays in NumPy. Perform operations


like splitting, joining, and replacing substrings on a given string array.

8. Write a Python program to compute the sine, cosine, and tangent of an array of angles in
radians. Also, demonstrate the use of other mathematical functions like exponential and
logarithms.

9. Write a Python program to perform element-wise addition, subtraction, multiplication,


and division of two NumPy arrays. Ensure the use of broadcasting where applicable.

10. Write a Python program to handle arrays containing NaN values. Demonstrate how to
detect NaN, replace NaN with a specified value, and calculate the sum of the array ignoring
NaN values.

You might also like