Answer to Question #293674 in Python for suresh

Question #293674

4. Create two tuples named numeric_tuple consisting of only integer values 10,20,30,40,50 and my_tuple which will have 30,60,50,’tup’ values

a. Find the minimum value from the numeric_tuple.

b. Concatenate my_tuple with numeric_tuple and store the result in r1.

c. Duplicate the tuple named my_tuple 2 times and store that in ‘newdupli’.


5. Find the total number of elements present in the below set:

 

6. Create an array with whole numbers values from 0 to 10 and find what is the command to extract the elements in the following sequence - 

array ([7,4,1])


7. Create a NumPy array having user input values and convert the integer type to the float type of the elements of the array. For instance:

Original array [1, 2, 3, 4] 

Array converted to a float type: [ 1. 2. 3. 4.]




1
Expert's answer
2022-02-04T07:59:42-0500
from array import *
import numpy as np

#4
numeric_tuple = (10, 20, 30, 40, 50)
my_tuple = (30, 60, 50)
#4a
min = numeric_tuple[0]
for i in numeric_tuple:
    if min>= i:
        min = i
print('4a: ', min)
#4b
r1 = my_tuple + numeric_tuple
print('4b: ', r1)
#4c
newdupli = my_tuple * 2
print('4c: ', newdupli)
#6
a = array('i', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
print('6: ', a[-4::-3])
#5
print('5: ', len(a))
#7
print('7: ')
n = np.array((), dtype=int)
for i in range(4):
    num = input(str(i+1)+'>')
    n = np.append(n, int(num))
print(n)
print(n.astype(float))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS