0% found this document useful (0 votes)
19 views5 pages

20BCS1975 - PYTHON Worksheet Exp 1.2

Uploaded by

Sidharth Thakur
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)
19 views5 pages

20BCS1975 - PYTHON Worksheet Exp 1.2

Uploaded by

Sidharth Thakur
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/ 5

Experiment Title: 1.

Student Name: Sidharth Kumar UID: 20BCS1997


Branch: BE CSE Section/Group: 609/A
Semester: 4th
Subject Name: PYTHON LAB

Q1. Python Program to check whether a given number is a palindrome.

CODE :

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):

print("The number is palindrome!")

else:

print("Not a palindrome!")
"""Division"""

c = a/b

print("The quotient of the number is : ", c)

OUTPUT :
Q2 Python Program to check Whether entered number is Armstrong or Not?.
CODE :

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")

OUTPUT:
Q3. Python program to Take three numbers from the user and print the greatest

Number.

CODE:

a=int(input("Enter a 1st number:"))

b=int(input("Enter a 1st number:"))

c=int(input("Enter a 1st number:"))

largest = 0

if a>b and a>c:

largest=a

elif b>c:

lagest=b

else:

largest=c

print(largest,” is the largest of three numbers.”)


OUTPUT :

You might also like