MENU
Question -

Create a function addNumbers(x) that takes a number as an argument and adds all the integers between 1 and the number (inclusive) and returns the total number.



Answer -

def add Numbers (num):
total = 0
i = 1
while i< = num:
total + = i
i+ = 1
return total

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×