Python Worksheet 1.2
Python Worksheet 1.2
WORKSHEET 1.2
1. Aim:
1. Write a Python Program to check whether a given number is a
palindrome.
2. Write a Python Program to check Whether entered number is
Armstrong or Not?
3. Write a Python Program to Take three numbers from the user and
print the greatest number
2. Source Code:
1. Palindrome
if str(num) == reverse_num:
print(num, "is a palindrome")
else:
print(num, "is not a palindrome")
2. Armstrong
n = len(str(num))
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** n
temp //= 10
if num == sum:
print(num, "is an Armstrong number")
else:
print(num, "is not an Armstrong number")
3. Greatest number
print(a,b,c)
3. Screenshot of Outputs:
1. Palindrome
2. Armstrong
3. Greatest