Computer Science, asked by shivaji4891, 4 months ago

calculate the sum of natural numbers from 20 to 30 by using phyton programming​

Answers

Answered by sritharina4617
2

Answer:

# Sum of natural numbers up to num

num = 16

if num < 0:

  print("Enter a positive number")

else:

  sum = 0

  # use while loop to iterate until zero

  while(num > 0):

      sum += num

      num -= 1

  print("The sum is", sum)

Explanation:

saty bless

Similar questions