Answer to Question #318573 in Python for Dhea M. Maddela

Question #318573

Develop a Python application that will accept two non-negative integers and store them in a list and will append ten additional values equivalent to the sum of the two previous elements of the list.


Sample Output:


First Number: 1

Second Number: 3

[1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322]



I need the code to have an output stated above.


1
Expert's answer
2022-03-26T15:29:47-0400
def sum_list(a, b):
    sum1 = a + b
    list1 = [a, b]
    for i in range(2,12):
        sum1 = list1[i-1] + list1[i-2]
        list1.append(sum1)
    return list1
sum_list(1,3)

[1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322]

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