Computer Science, asked by akash48252, 8 months ago

1) write a python program to
generate the
Sum of
First 20 natural number

Plz tell the correct answer to follow u ​

Answers

Answered by harshamani2020
0

Answer:

num = int(input("Enter the value of n: "))

hold = num

sum = 0

if num <= 0:

print("Enter a whole positive number!")

else:

while num > 0:

sum = sum + num

num = num - 1;

# displaying output

print("Sum of first", hold, "natural numbers is:")

Answered by valeriy69
0

\small\mathsf\color{pink}{Solution\: using\: python\: 3}

natural_nums = [x for x in range(1, 21)]

print(f"Sum: {sum(natural_nums)}")

\small\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions