Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sum of 1 to n number in python

#1 + 2 + 3 + 4 + ........... + n = ?
l = int(input("Enter the range = "))
sum = 0
for x in range(1, l+1):
    sum += x
    if x != l:
        print(x, "+ ", end='')
    else:
        print(x, end='')

print(" =", sum)
Comment

program to find sum till n natural numbers in python

#sum of natural number till n.
n=int(input('no. :'))
gross=0
no=0
while no < n:
    no+=1
    gross+=no
    print('no.', no ,'sum of n', gross)
print('no.',n,'total',gross)
Comment

PREVIOUS NEXT
Code Example
Python :: button in flask 
Python :: create django user command line 
Python :: how to code in python 
Python :: from time import sleep, time 
Python :: python csv add row 
Python :: get all combinations from two lists python 
Python :: count number of occurrences of all elements in list python 
Python :: select text in a div selenium python 
Python :: discord.py how to give a user a role 
Python :: how to Take Matrix input from user in Python 
Python :: pyqt5 latex 
Python :: python create 2d array deep copy 
Python :: get the system boot time in python 
Python :: run python script from c# 
Python :: update python in miniconda 
Python :: python pandas cumulative sum of column 
Python :: how to split string with comma in python 
Python :: dask show progress bar 
Python :: how to make python speak 
Python :: generate number of n bits python 
Python :: how to get width of an object in pyqt5 
Python :: nested dict to df 
Python :: rename a column in python 
Python :: tqdm parallel 
Python :: python snake game 
Python :: hot reloading flask 
Python :: python file name from absolute path 
Python :: python text fromatting rows 
Python :: pandas groupby histogram 
Python :: scoop bucket add extras 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =