
Jasimine J.
asked 09/02/20Python code using an array at GCSE level
Hello, I'm having trouble converting this algorithm into a python code using an array.
The algorithm is that: the code asks the user for input (of a integer) for the value of a,b,c,d,m and n. It then uses the input value to calculate 'h' using the formula: h=(a+b)*m+(c+d)*n. It then outputs the value of h.
Thanks
1 Expert Answer

Patrick B. answered 09/05/20
Math and computer tutor/teacher
Coeff = [0,1,2,3,4,5]
print('Input A:>')
A = input()
Coeff[0]=A
print('Input B:>')
B = input()
Coeff[1]=B
print('input c:>')
C=input()
Coeff[2]=C
print('input D:>')
D=input()
Coeff[3]=D
print('input M:>')
M = input()
Coeff[4]=M
print('input N')
N=input()
Coeff[5]=N
for iLoop in Coeff: print (iLoop)
A = int(Coeff[0])
B = int(Coeff[1])
C = int(Coeff[2])
D = int(Coeff[3])
M = int(Coeff[4])
N = int(Coeff[5])
H = (A+B)*M + (C+D)*N
print('Result H=' + str(H))
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
I do not see the purpose of using the array09/05/20