1-Create a week_tuple and assign the days of the week as strings to the week_tuple. b. Print out the elements in the week_tuple.
2-a. The following list has been declared as follows: credit_list = [24,3,15] b. Convert the credit_list to a tuple named credit_tuple. c. Print out the elements in the credit_tuple.
3-a. Write an initialize_list_values function that takes in a number for the number of elements in a list and an initial value for each element. The function creates a new list and appends the elements with the initial value to the new list. b. Pass in 5 and 3.4 as arguments to the intital_list_values and store the returned list in data_list. c. Use a loop to print the elements of the data_list. ---
4- Create a tuple named inventory_items_tuple which has Raspberry Pi 3, Raspberry Pi 2, and Raspberry Pi Camera Module. b. Create a tuple named out_of_stock_items_tuple which has Raspberry Pi Zero. (Hint: add a , after “Raspberry Pi Zero”.) c. Append these two tuples together into the all_items_tuple. Print out each element in the tuple using a for loop and use the len function to determine the number of elements in the tuple. --
5- Create a list of lists consisting of three rows and four columns, which were initially set to 0. b. Prompt the user to initialize each element in the list of lists. c. Compute the sum of all of the elements in the list. You may use the sum function. d. Prompt the user to enter a row number and use a loop to calculate the sum of the elements in the row and print out the sum.
#1
week_tuple=('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday')
print(week_tuple)
#2
credit_list = [24,3,15]
credit_tuple=tuple(credit_list)
print(credit_tuple)
#3
def initialize_list_values(n,v):
data_list=[]
for i in range(n):
data_list.append(v);
for i in data_list:
print(i)
initialize_list_values(5,3.4)
#4
inventory_items_tuple=('Raspberry Pi 3','Raspberry Pi 2','Raspberry Pi Camera')
out_of_stock_items_tuple=('Raspberry Pi Zero','a')
all_items=()
all_items=list(inventory_items_tuple)
all_items.append(out_of_stock_items_tuple[0])
all_items_tuple=tuple(all_items)
for i in all_items_tuple:
print(i)
print(len(all_items_tuple))
Here is the desired code. We are only allowed to complete 4
parts at a time.
Thank you
Get Answers For Free
Most questions answered within 1 hours.