Write a Python program that tests the function main and the functions discussed in parts a through g.
Create the following lists:
inStock - 2D list (row size:10, column
size:4)
alpha - 1D list with 20 elements.
beta - 1D list with 20 elements.
gamma = [11, 13, 15, 17]
delta = [3, 5, 2, 6, 10, 9, 7, 11, 1, 8]
a. Write the definition of the function setZero that initializes any one-dimensional list to 0 (alpha and beta).
b. Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha.
c. Write the definition of the function doubleArray that initializes the elements of beta to two times the corresponding elements in alpha.
d. Write the definition of the function copyGamma that sets the elements of the first row of inStock from gamma and the remaining rows of inStock to three times the previous row of inStock.
e. Write the definition of the function copyAlphaBeta that stores alpha into the first five rows of inStock and betainto the last five rows of inStock.
f. Write the definition of the function printArray that prints any one-dimensional list. The function must contain only one loop to print any one-dimensional list.
g. Write the definition of the function
setInStock that prompts the user to input the
elements for the first column of inStock. The
function should then set the elements in the remaining columns to
two times the
corresponding element in the previous column, minus the
corresponding element in delta.
################### PGM START ######################################
def setZero(a):
a=[0]*20
print(a)
def doubleArray(b,a):
for i in range(0,len(a)):
b[i]=2*a[i]
def copyGamma(iS,g):
iS[0]=g
for i in range(1,10):
for j in
range(0,4):
iS[i][j]=iS[i-1][j]*3
def copyAlphaBeta(iS,a,b):
k=0
for i in range(0,5):
for j in
range(0,4):
iS[i][j]=a[k]
k+=1
k=0
for i in range(5,10):
for j in
range(0,4):
iS[i][j]=b[k]
k+=1
def printArray(a):
for i in range(0,len(a)):
print(i)
def setInStock(iS,d):
for i in range(0,10):
for j in
range(1,4):
iS[i][j]=(2*iS[i][j-1])-d[i]
#main method
if __name__=="__main__":
alpha=[0]*20
beta=[0]*20
gamma=[11,13,15,17]
delta = [3, 5, 2, 6, 10, 9, 7, 11, 1, 8]
inStock=[]
for i in range(10):
inStock.append([0] *
4)
print("Alpha after initialization")
setZero(alpha)
print("Enter 20 integers:")
for i in range(0,20):
alpha[i]=int(input())
print("Alpha after reading 20 numbers")
print(alpha)
print("Beta after a call to doubleArray")
doubleArray(beta,alpha)
print(beta)
print("instock after a call to copyGamma")
copyGamma(inStock,gamma)
print(inStock)
copyAlphaBeta(inStock,alpha,beta)
print("instock after a call to
copyAlphaBeta")
print(inStock)
print("\nEnter 10 integers")
for i in range(0,10):
inStock[i][0]=int(input())
print("inStock after a call to
setInstock")
setInStock(inStock,delta)
print(inStock)
###################### PGM END #########################################
OUTPUT
###########
Write a Python program that tests the function main and the functions discussed in parts a...
Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine library procedures Objectives: 1. using register indirect addressing 2. passing parameters 3. generating “random” numbers 4. working with arrays Description: Write and test a MASM program to perform the following tasks: 1. Introduce the program. 2. Generate ARRAYSIZE random integers in the range [LO = 10 .. HI = 29], storing them in consecutive elements of an array. ARRAYSIZE should be set to 200....
You have this solution in Java, I am interested in this same solution for Python.One interesting application of two-dimensional arrays is magic squares. A magic square is a square matrix in which the sum of every row, every column, and bothdiagonals is the same. Magic squares have been studied for many years, and there are some particularly famous magic squares. In this exercise you will write code todetermine whether a square is magic.You should find that the first, second, and...
Task 2 Write a shell script program call cal3.sh to do the following. 1. Print the output "you must provide at least one month" when there is no argument 2. Print the calendar with specified month matching the argument when there is one argument $ ./cal3.sh 1 January 2016 Su Mo Tu We Th Fr Sa 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 24 25 26 27...
A soft drink manufacturer uses fire agents to handle premium distribution for is various products. The marketing director desired to study the timeliness with which the premiums are distributed. Twenty transactions for each agent were selected at random and the time lapse (in days) for handling each transaction was determined. The results follow: Agent 1 Agent 2 Agent 3 Agent 4 Agent 5 24 18 10 15 33 24 20 11 13 22 29 20 8 18 28 20 24...
Refer to the following array definition for questions 1 & 2 int numberArray[9)[11] 1. Write a statement that assigns 145 to the first column of the first row of this array. 2. Write a statement that assigns 18 to the last column of the last row of this array. values is a two-dimensional array of floats, with 10 rows and 20 columns. Write code that sums all of the elements in the array and stores the sum in the variable...
2. A=[17 18 12 15 20 22 25 26 28 29 30 21] and B=[11 20 25 28 29 13 14 25 22 33 10 23] Write a MATLAB code which will show which elements of A are more than B and their indices.
R$ ( pseudocode only, I just need the English written pseudocode) Write pseudocode for a program that prints a calendar such as the following: Su M T W Th F Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Write a program that, given a month and year, prints a calendar, such as June 2016 Su Mo Tu We Th Fr Sa 5 6 7 8 910 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 To find out the weekday of the first day of the month, call this function: Computes the weekday of a given date. @param year the year @param month the month (1=January 12=...
In C++ Make a program that takes a positive integer 'n' and write an n x n matrix whose entries are listed as snail Example: (See picture) for n=6 Ej. Para n-6 2 2 2 20 21 22 23 24 7 19 32 33 34 258 18 31 36 35 26 9 17 30 29 28 27 10 16 15 14 13 12 11
After discussing the issue with you and others in the Finance department, the manager decided to change the payment terms for Accounts Receivable. The payment time remained at 14 days, but the penalty for late payments was increased. After about 3 months under the new payment terms, you asked the manager to collect a second stratified random sample. The data is presented in the second column of the worksheet (see the tab titled, “Data – Case #2) under the Heading...