Westonci.ca offers quick and accurate answers to your questions. Join our community and get the insights you need today. Experience the convenience of getting reliable answers to your questions from a vast network of knowledgeable experts. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.

Write a program that asks the user for a positive nonzero integer value. The program should use a loop to get the sum of all the integers from 1 up to the number entered. For, example if the user enters 50 , the loop will find the sum of 1,2,3,4,...,50. while loop

Sagot :

num = 0

while num <= 0:

   num = int(input("Enter a number: "))

i = 1

total = 0

while i <= num:

   total += i

   i += 1

print(total)

I wrote my code in python 3.8. Best of luck.