DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
WORKSHEET 1.2
Student Name: Aman singh Aswal UID: 21BCS3399
Branch: CSE Section/Group: 611/A
Semester: 4
Subject Name: Programing in Python lab
1. Aim:
1) Python Program to check whether a given number is a
palindrome.
2) Python Program to check Whether entered number is Armstrong
or Not?
3) Python Program to Take three numbers from the user and print
the greatest number
2. Source Code:
1)
num=int(input("Enter a number:"))
temp=num
rev=0
while(num>0):
dig=num%10
rev=rev*10+dig
num=num//10
if(temp==rev):
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
print("The number is palindrome!")
else:
print("Not a palindrome!")
2)
num = int(input("Enter a number: "))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
3)
a = int(input('Enter the first value:'))
b =int(input('Enter the second value:'))
c = int(input('Enter the third value:'))
Greatest= 0
if a > b and a > c: greatest = a
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
if b > a and b > c:
greatest = b
if c > a and c > b:
greatest = c
print(greatest, "is the largest of three values.")
3. Screenshot of Outputs:
1)
2)
3)