1.
Python program to swap two variables
P = int ( input("Please enter value for P: "))
Q = int ( input("Please enter value for Q: "))
temp = P
P=Q
Q = print ("The Value of P after swapping: ", P)
print ("The Value of Q after swapping: ", Q)
2.Python program to convert Kilometres to Miles
km = float (input ("Please enter the speed of car in Kilometre as a unit: "))
miles = km * 0.621371
print ("The kimetre in Miles: ", miles)
3.Python program to convert Celsius to
Fahrenheit
C= float (input("Temperature value in degree Celsius: " ))
F = (C * 9/5) + 32
print ("The Fahrenheit temperature is",F)
4.Python Program to check if a Number is
Positive, Negative or Zero
a = float(input("Enter a number as input value: "))
if a > 0:
print("Number given by you is Positive")
elif a < 0:
print("Number given by you is Negative")
else:
print("Number given by you is zero")
5.Python Program to Check if a Number is Odd
or Even
num = int(input("Enter a number: "))
if (num % 2) == 0:
print("The number is Even number”)
else:
print(“The number is Odd number”)
6.Python Program to Check Leap Year
Year = int(input("Enter the number: "))
if((Year % 400 == 0) or
(Year % 100 != 0) and
(Year % 4 == 0)):
print("Given Year is a leap Year");
else:
print ("Given Year is not a leap Year")
7.Python Program to Check Prime Number
a = int(input("Enter an input number:"))
c=0
for i in range (1,a+1):
if(a%i==0):
c=c+1
if (c>2):
print("Not Prime")
else:
print("Prime")
break
else:
print (n)
8.Python Program to the sum of 1st 10 natural
numbers
sum=0
for i in range(1,11):
sum=sum+i
print(sum)