Page 350 - Information_Practice_Fliipbook_Class11
P. 350
asciiValue = 65
for x in range(1,i+1):
charValue = chr(asciiValue)
print(charValue,end='')
asciiValue += 1
print()
Program 18: Write a program that takes an integer as an input and checks whether it is a perfect square or not. In
number theory, a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the
number itself.
Ans. '''
Objective:
To check whether a number is perfect number
Input: number
Output: result whether it is perfect number or not
'''
number = int(input("Enter a Number: "))
sum = 0
for i in range(1, number):
if(number % i == 0):
sum = sum + i
if (sum == number):
print("Is a Perfect Number")
else:
print("Is NOT a Perfect Number")
Program 19: Write a program that takes a number as an input and checks whether it is an armstrong number or not.
The Armstrong number is a number that is equal to the sum of the cubes of its digits. For example, 0, 1, 153, 370, 371,
and 407 are the Armstrong numbers.
Ans. '''
Objective: To check whether a number is an armstrong number
Input: num
Output: result whether it is armstrong number or not
'''
num = int(input("Enter a Number: "))
n = num #storing the number for later usage
sumCubeDigits = 0
while n > 0:
336 Touchpad Informatics Practices-XI

