New course! Every coder should learn Generative AI!
Try a free lesson+ 35
N=100
sum=0
for i in range(1, N+1):
sum+=i
print(sum)
If we input 100 the result is 5050
+ 19
Ilyass Nafi
Try this:
N = int(input())
#your code goes here
num_list = list(range(N+1))
print(sum(num_list))
+ 12
N = int(input())
sum=0
for i in range(1, N+1):
sum+=i
print(sum)
+ 7
N=int(input())
sum=0
for i in range(1,N+1):
sum+=1
print(sum)
+ 3
N = int(input())
the_sum= sum(list(range(N+1)))
print(the_sum)
consider this story about the mathematician Carl Friedrich Gauss. When Gauss was a boy, a teacher wanted to give the class some busywork. The teacher told them to add up all the numbers from 0 to 100. Young Gauss came up with a clever trick to figure out the answer in a few seconds, but you can write a Python program with a for loop to do this calculation for you.
total = 0
for num in range(101):
total = total + num
print(total)
(Young Gauss figured out a way to solve the problem in seconds. There are 50 pairs of numbers that add up to 101: 1 + 100, 2 + 99, 3 + 98, and so on, until 50 + 51. Since 50 × 101 is 5,050, the sum of all the numbers from 0 to 100 is 5,050. Clever kid!)
+ 2
print(sum([x for x in range(N+1)]))
+ 2
Andrew Malenga
You should post your problem in Q&A Section. And show your attempts.
+ 1
https://www.dynamiccoding.tech/JUMP_LINK__&&__python__&&__JUMP_LINK-iterative-structure-python-loops/
Check out this blog so you will understand the working of range function and also get where do we add 100
+ 1
num = int(input())
nums = list(x for x in range(1, num+1))
print(sum(nums))
+ 1
n=int(input())
sum=0
for i in range(1,n+1):
sum+=i
print(sum)
+ 1
num_list = list(range(N+1))
print(sum(num_list))
+ 1
Try this
N=int(input())
Print(int(N*(N+1)/(2)))
0
Yes, but I forgot it. I was remembering it. Give it to me, please

0
N=int(input())
sen=0
for i in range(1,N+1):
sen+=i
print(sen)
0
num = int(input())
nums = list(x for x in range(1, num+1))
print(sum(nums))
0
N = int(input())
#your code goes here
print(N*(N+1)//2)
0
sum = 0
for num in range(100):
sum += num+1
print(sum)
0
# You are given
N = int(input())
#your code goes here
Total = 0
for x in range(1,N+1)
Total+=x
print(Total)
0
#your code goes here