#Program to convert distance from Meter to KM and meter
ch=int(input("Enter 1 for Meter to KM / Enter 2 for KM to Meter-"))
if ch==1:
d=float(input("Enter the distance in Meter-:"))
km=d/1000
print("The distance in KM-:",km)
elif ch==2:
d=float(input("Enter the distance in KM-:"))
m=d*1000
print("The distance in Meter-:",m)
else:
print("Wrong choice")
#Program to find volume of a Sphere and a Cuboid
ch=int(input("Enter 1 for volume of Sphere / Enter 2 for volume of Cuboid-"))
if ch==1:
r=int(input("Enter the radius of the Sphere-:"))
v=4/3*22/7*(r**3)
print("The volume of Sphere is-:",v)
elif ch==2:
l=int(input("Enter the length of the Cuboid-:"))
b=int(input("Enter the breadth of the Cuboid-:"))
h=int(input("Enter the height of the Cuboid-:"))
v=l*b*h
print("The volume of Cuboid is-:",v)
else:
print("Wrong choice")
#Program to create simple calculator performing only 4 basic operations
a=int(input("Enter a number-:"))
b=int(input("Enter another number-:"))
print("Addition-:",a+b)
print("Subtraction-:",a-b)
print("Multiplication-:",a*b)
print("Division-:",a/b)
#Program to check a year is leap year or not
year=int(input("Enter a valid year-:"))
if year%400==0:
print("The year is leap year")
elif year%4==0:
print("The year is leap year")
else:
print("The year is not a leap year")
#Program to print the even numbers with in a range
start=int(input("Enter the start value of the range-:"))
stop=int(input("Enter the stop value of the range-:"))
print("The even numbers are-:")
for i in range(start,stop+1):
if i%2==0:
print(i)
#Program to print the sum of natural numbers with in a range
start=int(input("Enter the start value of the range-:"))
stop=int(input("Enter the stop value of the range-:"))
s=0
for i in range(start,stop+1):
s=s+i
print("The sum of natural numbers is-:",s)
#Program to count number of vowels in a string
str1=input("Enter the string-:")
vowels='aeiouAEIOU'
l=len(str1)
c=0
for i in range(0,l):
if str1[i] in vowels:
c=c+1
print("The number of vowels is-:",c)
#Program to check a string is palindrome or not
str1=input("Enter the string-:")
if str1==str1[: : -1]: #str1[: : -1] mean reverse of string
print("The string is palindrome")
else:
print("The string is not palindrome")
#Program to print the lowest number from a list enter by the user
n=int(input("Enter the length of the list-:"))
l=[]
for i in range(1,n+1):
e=int(input("Enter the element of the list-:"))
l.append(e)
print("The list is-:",l)
mn=l[0]
for i in range(0,n):
if mn>l[i]:
mn=l[i]
print("The lowest number in the list is-:",mn)
#Program to print the numbers divisible by both 3 & 7 from a list enter by the
user
n=int(input("Enter the length of the list-:"))
l=[]
for i in range(1,n+1):
e=int(input("Enter the element of the list-:"))
l.append(e)
print("The list is-:",l)
print("The numbers divisible by both 3 & 7 are-:")
for i in range(0,n):
if l[i]%3==0 and l[i]%7==0:
print(l[i])