Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

#1 Swap the number without using third varible?

a=int(input("Enter the first number"))


b=int(input("Enter the first number"))
print("The number is:",a,b)
a,b=b,a
print("The swap number is:",a,b)

account_circle Enter the first number4


Enter the first number5
The number is: 4 5
The swap number is: 5 4

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

Enter the number:4567


The reverse number is: 7654

#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

#4. Write a program that will reverse a four digit number.


#Also it checks whether the reverse number it equal or not.
a=int(input("Enter the number:"))
original_num=a
rev=0
r=0
while(a!=0):
r=a%10
rev=rev*10+r
a=a//10
print("The reverse number is:",rev)
if original_num==rev:
print("It is similar")
else:
print("It is not Similar")

Enter the number:2345


The reverse number is: 5432
It is not Similar

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

Enter the x coordinates point:4


Enter the x oordinate point:6
Enter the y oordinate point:7
Enter the y oordinate point:9
The euclidean distance between two coordinates : 2.828427124746

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

Enter the number:12


The given number is 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)

Enter the first number:2


Enter the second number:3
Enter the third number:1
The square of each digit 14
#8. Write a program that will check whether the number is Armstrong
a=int(input("Enter the number:"))
original_num=a
rev=0
sum=0
while(a!=0):
rev=a%10
sum=sum+pow(rev,3)
a=a//10
print("The sum of the number is:",sum)
if original_num==a:
print("The number is Armstrong number")
else:
print("The number is not Armstrong number")

Enter the number:153


The sum of the number is: 153
The number is not Armstrong number

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

Enter the number:1634


The sum of the number is: 1634
The number is not narcissist number
#10. Write a program to create login access of an employee and check
employee_username = "employee123"
employee_password = "password123"
username = input("Enter your username: ")
password = input("Enter your password: ")
if username == employee_username and password == employee_password:
print("Login successful. Welcome, employee!")
else:
print("Incorrect username or password. Please try again.")

Enter your username: employee123


Enter your password: password123
Login successful. Welcome, employee!

You might also like