0% found this document useful (0 votes)
38 views

Python 1.2

The document contains a worksheet for a Python programming lab assignment. It includes 3 programming problems - to check if a number is a palindrome, check if a number is an Armstrong number, and find the greatest of 3 user-input numbers. For each problem, it lists the aim, provides the Python source code to solve it, and indicates screenshots of outputs would be included.

Uploaded by

Aman Singh Aswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Python 1.2

The document contains a worksheet for a Python programming lab assignment. It includes 3 programming problems - to check if a number is a palindrome, check if a number is an Armstrong number, and find the greatest of 3 user-input numbers. For each problem, it lists the aim, provides the Python source code to solve it, and indicates screenshots of outputs would be included.

Uploaded by

Aman Singh Aswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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)

You might also like