Assignment-1 - Colab
Assignment-1 - Colab
#2. Write a Program to extract each digit from an integer in the reve
a=int(input("Enter the number:"))
rev=0
r=0
while(a!=0):
r=a%10
rev=rev*10+r
a=a//10
print("The reverse number is:",rev)
#3. Write a program that will give you the sum of 3 digits
a=int(input("Enter the number:"))
num=0;
sum=0
while(a!=0):
num=a%10
sum=sum+num
a=a//10
print("The sum of the number is:",sum)
Enter the number:234
The sum of the number is: 9
#5. Write a program to find the euclidean distance between two coord
from math import sqrt
x1=int(input("Enter the x coordinates point:"))
x2=int(input("Enter the x oordinate point:"))
y1=int(input("Enter the y oordinate point:"))
y2=int(input("Enter the y oordinate point:"))
dist=math.sqrt(pow(y2-y1,2)+pow(x2-x1,2))
print("The euclidean distance between two coordinates :",dist)
#6. Write a program that will tell whether the given number is divis
num=int(input("Enter the number:"))
if(num%3==0) and (num%6==0):
print("The given number is divisible by 3 & 6")
else:
print("The given number is not divisible by 3 & 6")
#7.Write a program that will take three digits from the user and add
x=int(input("Enter the first number:"))
y=int(input("Enter the second number:"))
z=int(input("Enter the third number:"))
sum=pow(x,2)+pow(y,2)+pow(z,2)
print("The square of each digit",sum)
#9. Write a program that will take user input of (4 digits number) a
a=int(input("Enter the number:"))
original_num=a
rev=0
sum=0
while(a!=0):
rev=a%10
sum=sum+pow(rev,4)
a=a//10
print("The sum of the number is:",sum)
if original_num==a:
print("The number is narcissist number")
else:
print("The number is not narcissist number")