0% found this document useful (0 votes)
3 views2 pages

Python Programs for Number Manipulation

The document contains several Python programs that perform various tasks, including calculating the sum of digits of a three-digit number, reversing a two-digit number, checking if a three-digit number is a palindrome, reversing a four-digit number, finding the largest of three numbers, and calculating sums of three numbers with and without duplicates. Additionally, it includes a program to find multiples of a divisor from five given numbers. Each program prompts the user for input and outputs the results accordingly.

Uploaded by

krishnajangirdps
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)
3 views2 pages

Python Programs for Number Manipulation

The document contains several Python programs that perform various tasks, including calculating the sum of digits of a three-digit number, reversing a two-digit number, checking if a three-digit number is a palindrome, reversing a four-digit number, finding the largest of three numbers, and calculating sums of three numbers with and without duplicates. Additionally, it includes a program to find multiples of a divisor from five given numbers. Each program prompts the user for input and outputs the results accordingly.

Uploaded by

krishnajangirdps
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

'''#wAP to find sum of digits of 3digit no.

a=int(input("Enter a no."))
b=a%10
c=a//100
d=(a//10)%10
print("Sum of digits =", b+c+d)

#WAP to reverse a two digit no.


a=int(input("Enter a no."))
b=a%10
c=a//10
k= b*10+c
print(k)

#WAP to check if the entered 3 digit no. is palandrome or not


a=int(input("Enter a no."))
b=a%10
c=a//100
if b==c:
print("the no. is palandrome")
else:
print("The no. is not a palandrome")

#WAP to to enter a 4 digit and reverse it

a=int(input("Enter a no."))
b=a%10
c=a//1000
d=(a//100)%10
e=(a//10)%10
k= b*1000+d*100+e*10+c
print(k)

#WAP to enter 3 no and print the largest of the three usingg if statement
a=int(input("Enter 1st No."))
b=int(input("Enter 2nd NO."))
c=int(input("Enter 3rd No."))
max=a
if b>max:
max=b
if c>max:
max=c
print("The largest NO. is " ,max)

#WAP that input 3 no and calculates two sum as per1=int(input("enter number 1:"))

sum1=sum2=0
num1=int(input("enter number 1:"))
num2=int(input("enter number 2:"))
num3=int(input("enter number 3:"))
sum1=num1+num2+num3
if num1!=num2 and num1!=num3:
sum2+=num1
if num2!=num1 and num2!=num3:
sum2+=num2
if num3!=num1 and num3!=num2:
sum2=+num3
print("numbers are",num1,num2,num3)
print("sum of three given numbers is",sum1)
print("sum of non duplicate numbers is",sum2)

#alternative
sum1=sum2=0
num1=int(input("enter number 1"))
num2=int(input("enter number 2"))
num3=int(input("enter number 3"))
if num1==num2:
if num3!=num1:
sum2+=num3
else:
if num1==num3:
sum2+=num2
else:
if num2==num3:
sum2+=num1
else:
sum2+=num1+num2+num3
print("numbers are",num1,num2,num3)
print("sum of the given numbers is",sum1)
print("sum of non duplicate numbers is",sum2)'''

#wap to find the multiples of a number (the diviser) out of


# given five numbers

print("enter five numbers below")


num1=float(input("first number:"))
num2=float(input("second number:"))
num3=float(input("third number:"))
num4=float(input("fourth number:"))
num5=float(input("fifth number:"))
div=float(input("Divisior number:"))
count=0
print("Multiples of ","are:")
remainder=num1%div
if remainder==0:
print(num1,sep=" ")
count+=1
remainder=num2%div
if remainder==0:
print(num2,sep=" ")
count+=1
remainder=num3%div
if remainder==0:
print(num3,sep=" ")
count+=1
remainder=num4%div
if remainder==0:
print(num4,sep=" ")
count+=1
remainder=num5%div
if remainder==0:
print(num5, sep=" ")
count+=1
print()
print(count,"Multiples of ",div,"found")

You might also like