Bitwise Operator, for Loop
Print the series 1 2 3 4 5 6 to the user up to n terms . Get n from the user
n=int(input("Enter the count"))
for i in range(1,n+1):
print(i)
Output
Print out all the numbers that are mutiples of 4 from 1 to 100
for i in range(1,101):
if i%4==0:
print(i)
Output
Write a program that calculates the squares and cubes and four times of the numbers from 20 to 1 and use tabs to print the values
for i in range(20,0,-1):
print("Value=",i,"Square=",i**2,"Cube=",i**3,"Fours=",i**4)
Output
Write an program to find the numbers between 1 and 100 that are not divisible by 2, 3, and 5.
for i in range(1,101):
if i%2!=0 and i%3!=0 and i%5!=0:
print(i,end=" ")
Output
Design an program for the summation of the following series up to n terms as entered by the user.
1,2,4,7,11,16,22
n=int(input("enter the count "))
k=1
sum=0
for i in range(1,n+1):
sum=sum+k
k=k+i
print("The sum of the series is ",sum)
Output
Find the factorial of a given number
n=int(input("enter the count "))
fact=1
for i in range(1,n+1):
fact=fact*i
print("The factorial is ", fact)
Output
Compute the sum of 1+3+5+7… up to n terms as given by the user
n=int(input("enter the count "))
sum=0
k=1
for i in range(n):
sum=sum+k
k=k+2
print("The sum is ", sum)
Output