NumPy: Basics
✕Indexing and Slicing
Question 1 of 4
- Create a NumPy array from this list. Display
array,it's shape,items data type. - Display the temperature of
12 PM. - Replace the temperature of
2 PMwith value-1. - Display temperature from
10 AMto6 PM. - Delete the temperature of
2 PM. - Insert the value for
2 PMwith median temperature of the day. - Display
minimumtemperature of day and time it occurred. - Display
maximumtemperature of day and time it occurred. - Calculate the
standard deviationof the temperatures.
Store sensor data of 24 hr temperature in a List astmp_data = [1.3, 1.4, .., 0.8].- Create a NumPy array from this list. Display
Modifying Arrays
Question 2 of 4
- Create a NumPy array from this list. Display
array,it's shape,items data type. - Add a new row at end for
Sitawith roleStudent. - Add a new column at end for
Agewith values30,25,28,22. - Delete the row for
Ram. - Delete the column for
Age. - Add a 2 column as
Citywith valuesKathmandu,Mumbai,Newyork. - Display the name of all students.
- Display the role of
Rabindra. - Display all info for
Shyam.
Assign info as[["Rabindra", "Instructor], ["Ram", "Student], ["Shyam", "Student"]].- Create a NumPy array from this list. Display
Vectorized Operation, Broadcast
Question 3 of 4
- Create a NumPy array from it as
cp_ar. Displayarray,it's shape,items data type. - Assuming a 13% profit, calculate the selling price for each product. Assign it as
sp_ar. - Calculate the profit for each product using
sp_arandcp_ar. Assign it asprofit_ar. - Create function
price_rangethat accepts price & categorizes it aslow,mediumorhighdepending if its value isbelow 150, between150-250orabove 250. - Find price category for each product using
price_rangeas store it asprice_cat_ar. - Convert values of
price_cat_arintouppercase,lowercase,titlecase& Display result. - Create
rev_arby subtracting 2 fromprofit_ar. - Round each element of
sp_arupto 2 decimal and store it assp_ar_rounded.
Store cost price of products ascost_prices = [100, 150, 200, 250, 300].- Create a NumPy array from it as
Vectorized Operation, Broadcast
Question 4 of 4
- Store stock price as
[100, 150, 200, 250, 300, 270]. Using it calculate return for each day & store asreturns_ar. (return = (current_price - previous_price)/previous_price) - A man deposits each day on bank as
[10, 15, 20, 25, 30, 27]. Generate a arraytotal_amount_arthat shows total amount deposited over the time.[10, 25, 45, ...]. - You have a co2 emission data for 5 years as
[100, 150, 200, 250, 300]. Normalize this reading so that value will transformed from 0-1. (x_norm = (x - min) / (max - min)) - Write a function
incrment_salarythat takes current salary and returns increased salary. Hike Rule:<1000 => 20%,1000-5000 => 10%,>5000 => 5%. - Apply
incrment_salaryto array[800, 1200, 3000, 6000]. Store result asnew_salary_ar.
- Store stock price as
