Python program to swap two variables
a=int(input(‘Enter any number: ‘))
b=int(input(‘Enter any other number: ‘))
print(‘before swapping the values are…..’)
print(‘a=’,a)
print(‘b=’,b)
temp=a
a=b
b=temp
print(‘after the swapping values are….’)
print(‘a=’,a)
print(‘b=’,b)
Enter any number: 10
Enter any other number: 20
before swapping the values are…..
a= 10
b= 20
after the swapping values are….
a= 20
b= 10
a=int(input(‘Enter any number: ‘))
b=int(input(‘Enter any other number: ‘))
print(‘before swapping the values are…..’)
print(‘a=’,a)
print(‘b=’,b)
a=a+b
b=a-b
a=a-b
print(‘after the swapping values are….’)
print(‘a=’,a)
print(‘b=’,b)
Enter any number: 5
Enter any other number: 9
before swapping the values are…..
a= 5
b= 9
after the swapping values are….
a= 9
b= 5
Or you can write a simple one-line code to swap the values of two variables.
a=int(input(‘Enter any number: ‘))
b=int(input(‘Enter any other number: ‘))
print(‘before swapping the values are…..’)
print(‘a=’,a)
print(‘b=’,b)
a,b = b,a
print(‘after the swapping values are….’)
print(‘a=’,a)
print(‘b=’,b)
Enter any number: 20
Enter any other number: 11
before swapping the values are…..
a= 20
b= 11
after the swapping values are….
a= 11
b= 20
Python Program to add two numbers
Python program to find Area of Square
Python program to find Area of Triangle
Python program to swap two variables
Python program to convert Celsius to Fahrenheit
Python program to generate Random Number
Python program to convert Miles to Kolometers
Python program to find Largest of 2 numbers
Python program to check if number is Odd or Even
Python program to check if number is Positive Negative or Zero
Python program to check Leap Year
Types of Loop in Python
Python program to check Prime Number
Python program to Calculate Sum of N Natural Numbers
Python program to find sum of All Even Number between 1 to 10
Python program to find sum of All Odd Number between 1 to 10
Python program to check Armstrong Number