Question

1-Create a week_tuple and assign the days of the week as strings to the week_tuple. b....

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.

Homework Answers

Answer #1
#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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c....
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c. Write a for loop which will display this set of values 2,4,6,8,10,12,14,16. d. Write a while which will display this set of values 16,13,10,7,4,1,-2. e. Write a for loop which will print ‘Loops are fun’ three times. f. Write a while loop that will prompt you for four numbers. Convert the number to an integer. Compute the power as power = power ** number....
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an array of ints, an int value named element, and an int value named end. Return a bool based on whether the element appears in the array starting from index 0 and up to but not including the end index. Generate Random Array Write a function that takes as parameters an array of integers and another integer for the size of the array. Create a...
c) A function named tallied_data() that takes in a nested list (Use this on the data...
c) A function named tallied_data() that takes in a nested list (Use this on the data from part 1, but it should be able to be used to solve similar problems), indices for two columns and returns a tallied list. The inputs are: i) a nested list, ii) an index for the ‘reference column’/ ‘category’ (col_ref) iii) another index for the column to be tallied (col_tally) iv) this function returns a list of tuples where each element is a tuple...
In the code space provided in Matlab Grader, create a function that: 1. Accepts an input...
In the code space provided in Matlab Grader, create a function that: 1. Accepts an input matrix A as its only input argument. Matrix A is a 3x3 matrix of random integers between 1 and 4 2. Produces and output matrix B as its only output argument. Matrix B will also be a 3x3 matrix. 3. Calculates the elements of matrix B such that: a. the values of B along the diagonal are equal to the respective elements in A...
In this programming exercise you will create an algorithm for solving the following version of the...
In this programming exercise you will create an algorithm for solving the following version of the m Smallest Numbers problem.   Instead of just returning the m smallest values as in homework 1, you want to return a list of the positions where the m smallest values are located without changing the original array. Your algorithm should meet the following specifications: mSmallest( L[1..n], m ) Pre: L is a list of distinct integer values. n is the number of elements in...
Python 3 Conversion and exception handling Create a function that asks the user to enter a...
Python 3 Conversion and exception handling Create a function that asks the user to enter a number and returns the number. * function name: get_int * parameters: prompt (string) * returns: int * operation: Use the "prompt" parameter as the parameter to an input() call in order to ask the user for a number. Convert the number to a int using the int() function and return this number from the function. but - If the user enters something that cannot...
In C programming language please. -Construct a program that will make use of user defined functions,...
In C programming language please. -Construct a program that will make use of user defined functions, the do/while loop, the for loop and selection. -Using a do/while loop, your program will ask/prompt the user to enter in a positive value representing the number of values they wish to have processed by the program or a value to quit/exit. -If the user enters in a 0 or negative number the program should exit with a message to the user indicating they...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns the index of the first occurance of the smallest value in the array. Your function must be able to process all the elements in the array. Create a function prototype and function definition (after the main function). Your main function should declare a 100 element integer array. Prompt the user for the number of integers to enter and then prompt the user for each...
Questions: 1. (5 marks) Create a VB.NET Console Application that defines a function Smallest and calls...
Questions: 1. Create a VB.NET Console Application that defines a function Smallest and calls this function from the main program. The function Smallest takes three parameters, all of the Integer data type, and returns the value of the smallest among the three parameters. The main program should (1) Prompt a message (using Console.WriteLine) to ask the user to input three integers. (2) Call the built-in function Console.ReadLine() three times to get the user’s input. (3) Convert the user’s input from...