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

Assignment1_Python-Numpy

The document outlines a series of Python and Numpy exercises designed to familiarize users with basic data structures, operations, and functions. Tasks include generating tuples and dictionaries, creating random arrays, performing array operations, and manipulating strings. It also covers advanced topics like reshaping arrays, calculating statistical measures, and finding eigenvalues and eigenvectors.

Uploaded by

deepakbond008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Assignment1_Python-Numpy

The document outlines a series of Python and Numpy exercises designed to familiarize users with basic data structures, operations, and functions. Tasks include generating tuples and dictionaries, creating random arrays, performing array operations, and manipulating strings. It also covers advanced topics like reshaping arrays, calculating statistical measures, and finding eigenvalues and eigenvectors.

Uploaded by

deepakbond008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment1a (Basis for Lab 1)

(Python & Numpy basics)

 Basic Python data structures, String operations, Math operators, Random


number generators, Arrays, Array Operations etc
1. Generate a tuple from the set ["aman", "222", 777, 400.4]
2. Create a dictionary of your basic data : (a) Roll No (b) Last Name (c) First Name
(d) Date of birth. Print out the values and keys.
3. Use rand function to generate a 2-dimensional random array with seed.
4. Generate a single random number in [0.0, 1.0]. Find the absolute value of (-1234)
5. Return a random integer N such that 20 <= N <= 90.
6. Given a population or set[11, 12, 13,14, 15]
o Return a 3 length list of unique elements without replacement.
o Shuffle the above set
o Print a random number from the set
7. Write the text "The King is Dead, Long Live The King" on to a file in your hard
drive; read and print the text.
8. Create an illustrative function to demonstrate use of: (a) if, elif and else (b) for,
while, break and continue.
9. Given a string "The King is Dead, Long Live The King"
o Print the complete string
o Print first character of the string
o Print characters starting from 3rd to 5th
o Print string starting from 3rd character
o Split the words
10. An array can be created from a list: Create an array from a list comprising of
numbers 1,4,5,8 (treat them as floats). Slice the above array to display first and
second elements
11. Arrays can be multidimensional. Create a two-dimensional array of (1,2,3)
and (4,5,6).
12. Array slicing works with multiple dimensions in the same way as usual,
applying each slice specification as a filter to a specified dimension. Consider
two-dimensional array of (1,2,3) and (4,5,6).
o Slice and display the 2nd row.
o Write code to display as array([2., 5.])
o Find the length of the array.
13. Arrays can be reshaped using tuples that specify new dimensions. Turn a ten-
element one-dimensional array into a two-dimensional one whose first axis has
five elements and whose second axis has two elements. Obtain the transpose of
the array
14. Create an array from a list of 1,2 and 3.
15. Fill an array [1,2,3] with a single value [9,9,9].
16. Sum the elements of array [2,4,5].
17. Give the products of array [77,74,75]
18. Given an array [2,1,9,1,2,22,1,1,4,55,6,2,56]. Find mean, variance, max, min,
argmin, median, argmax and standard deviation.
19. Extract unique elements from an array: [1, 1, 4, 5, 5, 5, 7] and sort it.
20. Find dot product of two arrays [1, 2, 3]and [0, 1, 1].
21. Find the eigenvalues and eigenvectors of matrix A.
[
A= 2 −12
1 −5 ]
22. Given an array with [11, 22, 11, 31], [25, 33, 31, 28]]. Treat as floats. Find the
correlation coefficients.
-----------------------------------------------------------------------------------------------

You might also like