Python Codes
Python Codes
Python Codes
CODES
i=1
while i<10:
print(i*i)
i=i+1
Fruits[“apple”,”mango”,”banana”,”grape”]
For x in fruits:
Print(x)
for i in range(1,11):
result=n*i
print(n,"*",i,"=",result)
for i in range(1,n+1,2):
print(i)
for i in range(1,n+1,2):
print(i)
6) Program to display number till the number given by user
i=0
n=int(input('enter a number'))
while i<=n:
print(i)
i=i+1
i=10
while i>0:
print(i)
i=i-1
for x in range(1,11):
print(x)
for x in range(1,20,3):
print(x)
for x in range(30,1,-3):
print(x)
n=int(input('enter number'))
x=0
for i in range(1,n+1):
x+=i
print(x)
12) Program to print(sum) Write a Program to find the sum of the following series:
S = 1 + 4 + 9 + 16 + ---------n2:
n=int(input('enter a number:'))
i=1
sum=0
while i<=n:
sum=sum+i*i
i=i+1
print(sum)
13) Write a Program to calculate and print sum of integers of the first n natural numbers. (accept
n from user):
n=int(input('enter a number'))
i=1
sum=0
while i<=n:
sum=sum+i
i=i+1
print(sum)