Hi! Can you please check my answers to these practice questions please? I just want to make sure what I did is correct. Thank you!
Qwiu Complete the following programming exercises. (a) Write an expression that divides the number 28 by 4 and stores the result in a variable called my_number . [6] my_number = 28/4 (b) Create an object called my_int that contains an integer with a value of 5. Write another line of code to demonstrate that my_int is indeed an integer. [7] my_int = 5 type(my_int) int (o) Create an object called my_float that stores the value 5 as a oat. Write another line of code that demonstrates that my_float is indeed a oat. [8] my_float = 5.0 type ( my_float) float (d) Add together my_int and my_float and store the result in a variable called my_sum . You must use the variable names my_int and my_f'loat . [9] my_sum = my_int+rny_float (e) What is the type of my_sum ? A. Int B. Float C. String [ ] q1e_answer = "B" #@param ["A", "B", "C"] q1e_answer: B . (f) Write one line of code to convert my_int to a string and store it in a variable called my_st ring . [10] my_st ring = st r( my_int) (9) Write one line of code to multiply the my_st ring variable by 3. Recall: In Python, mathematical operators like + and * are "overloaded\" so that they work for more than just numeric values. For example, if the addition operator + is used with two strings, Python will concatenate them, i.e., combine them into a new string where the contents of the second string appear directly after the last character of the rst string [11] my_st ring*3 '555' v Question 2: Lists and arra s Complete the following programming exercises. (a) Create four variables based on the following list of cell phones and their price in USD, given in parentheses. The value for each variable should be the price of that cell phone as written. - iPhone (799) - Galaxy (649) 0 Pixel (699) - OnePlus (729) Then, write code that uses arithmetic (i.e., do not import a package) to calculate the mean price of the four phones, using the names of the phone variables in the mathematical expression, and store this mean value in a variable called phone_price_mean . [13] iphone = 799 galaxy = 649 pixel = 699 oneplus = 729 phone_price_mean = (iphone+galaxy+pixel+oneplus)/4 (b) We will now calculate the same mean as in Question 2a above, but this time we will use a list variable. Create a list variable called phone_price_list containing four numeric items that correspond to the prices of the four phones. Write a second line of code that uses arithmetic (still no package importing) to find the mean of the elements in phone_price_list and assign this mean to a variable called phone_price_meanz . [14] phone_price_list = [799,649,699,729] phone_price_meanz = (799+649+699+729)/4 (c) We will now calculate the same mean as in Question 1a, but this time we will use a NumPy array variable. Create a NumPy array called phone_price_array containing four numeric items, one for each phone price. Find the mean of phone_price_array and store it in the variable phone_price_mean3 . Note: We have provided you with starter code containing the line import numpy as np. This tells Python to load the NumPy library into memory so that you can call its functions with the np. prefix, e.g., np. sqrt ( ) . You only need to run this import statement once per notebook session [19] import numpy as np phone_price_array = np. array ( [799, 649, 699, 729] ) phone_price_mean3 = np. mean (phone_price_array) (d) Write a conditional statement to check that phone_price_mean2 is equal to phone_price_mean . Then write a second conditional statement to check that phone_price_mean3 is equal to phone_price_mean2. phone_price_mean == phone_price_mean2 phone_price_mean2 == phone_price_mean3 [ True (e) We can also use built-in functions in Python to make certain calculations. Write code to find the minimum value in the list called phone_price_list , and store this minimum value in a variable named phone_price_min . Then print the value of phone_price_min to confirm that the previous line worked. [21] phone_price_min = min (phone_price_list) phone_price_min 649(f) Now find the maximum of phone_price_array . For this answer, do not store the maximum in a variable, print it directly instead. [22] max (phone_price_array) 799 (g) Given the similarities in some of the functionality of arrays and lists, why might we prefer to use a NumPy array instead of a list? A. You can perform arithmetic on the objects in an array, but not a list B. Arrays can store integers and strings, whereas lists can only store integers C. A & B D. Arrays consume less memory E. Mathematical operations typically run faster on arrays F. D & E [ ] q2f_answer = "A" #@param ["A", "B", "C", "D", "E", "F"] q2f_answer: A