Python Program Class 11
Python Program Class 11
SUBJECT-COMPUTER SCIENCE
CLASS-XI
if y == 0:
return 1
if y % 2 == 0:
return power(x, y // 2) * power(x, y // 2)
n = order(x)
temp = x
sum1 = 0
# If condition satisfies
return (sum1 == x)
# Driver code
x = 153
print(isArmstrong(x))
x = 1253
print(isArmstrong(x))
2)Determine whether a given number is prime or not.
# Python program to check if
# given number is prime or not
num = 11
# Iterate from 2 to n / 2
for i in range(2, int(num/2)+1):
else:
print(num, "is not a prime number")
3)Write a program to print prime numbers from 1 to N
# Python3 program to display first N Prime numbers
# Driver code
N = 100;
#check for every number from 1 to N
for i in range(1,N+1):
#check if current number is prime
if(isPrime(i)):
print(i,end=" ")
4)Write a program to print perfect number till 1000
# Python3 code to check if a given
# number is perfect or not
# Driver program
print("Below are all perfect numbers till 10000")
n=2
for n in range (10000):
if isPerfect (n):
print(n , " is a perfect number")
# Python3 Program to
# of first n natural
# numbers
# natural numbers
def squaresum(n) :
# Iterate i from 1
# and n finding
# square of i and
# add to sum.
sm = 0
sm = sm + (i * i)
return sm
# Driven Program
n=4
print(squaresum(n))
return sum
# Driver Function
n=5
print(sumOfSeries(n))
# define a function
def compute_hcf(x, y):
num1 = 54
num2 = 24
while(True):
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1
return lcm
num1 = 54
num2 = 24