#4b. Codding in Python {UNIT CONVERTER}.
#Unit Converter
print ("Press 1 for Temperature converter;Press 2 for cm-inch converter; Press 3 for mile-km converter")
a=int(input("Enter choice:"))
if (a==1):
print("Press 1 for C - F; Press 2 for F - K; Press 3 for C - K")
b=int(input("Enter choice:"))
if(b==1):
print("Press 1 for C - F; Press 2 for F - C")
z=int(input("Enter choice:"))
if(z==1):
c=int(input("Enter value in C :"))
f=(9*c-160)/5
print (f,"F")
if(z==2):
g=int(input("Enter value in F :"))
d=(5*g+160)/9
print (d,"C")
if(z>2) or (z<1):
print("Wrong choice !! Retry")
if(b==2):
print("Press 1 for K - F; Press 2 for F - K")
z=int(input("Enter choice:"))
if(z==1):
k=int(input("Enter value in K :"))
h=(-2457+9*k+160)/5
print (h,"F")
if(z==2):
i=int(input("Enter value in F :"))
l= (2457+5*i-160)/9
print (l,"F")
if(z>2) or (z<1):
print("Wrong choice !! Retry")
if(b==3):
print("Press 1 for K - C; Press 2 for F - C")
z=int(input("Enter choice:"))
if(z==1):
k=int(input("Enter value in K :"))
h=k-273
print (h,"C")
if(z==2):
i=int(input("Enter value in C :"))
l=i+273
print (l,"K")
if(z>2)or(z<1):print("Wrong choice !! retry")
if(b>3) or (b<1):
print("Wrong choice !! retry")
if(a==2):
print("Press 1 for cm - inch ; Press 2 for inch - cm")
q=int(input("Enter choice: "))
if (q==1):
cm=int(input("Enter value in cm :"))
inch=2.5*cm
print( inch ,
"inch")
if (q==2):
inhc=int(input("Enter value in inch :"))
mc=10*inhc/25
print(mc)
if(q>2) or (q<1):
print("Wrong choice !! Retry")
if(a==3):
print("Press 1 for mile - km ; Press 2 for km - mile")
w=int(input("Enter choice:"))
if (w==1):
mile=int(input("Enter value in mile :"))
km=(25*mile)/29
print(km)
if (w==2):
km=int(input("Enter value in km :"))
mk=116*miel/100
print(miel)
if(w>2) or (w<1):
print("Wrong choice !! Retry")
if(a>3) or (a<1):
print("Wrong choice !! Retry")
print ("Answers given may be rounded off")
Download CODES here.
CLICK HERE for online Python.
print ("Press 1 for Temperature converter;Press 2 for cm-inch converter; Press 3 for mile-km converter")
a=int(input("Enter choice:"))
if (a==1):
print("Press 1 for C - F; Press 2 for F - K; Press 3 for C - K")
b=int(input("Enter choice:"))
if(b==1):
print("Press 1 for C - F; Press 2 for F - C")
z=int(input("Enter choice:"))
if(z==1):
c=int(input("Enter value in C :"))
f=(9*c-160)/5
print (f,"F")
if(z==2):
g=int(input("Enter value in F :"))
d=(5*g+160)/9
print (d,"C")
if(z>2) or (z<1):
print("Wrong choice !! Retry")
if(b==2):
print("Press 1 for K - F; Press 2 for F - K")
z=int(input("Enter choice:"))
if(z==1):
k=int(input("Enter value in K :"))
h=(-2457+9*k+160)/5
print (h,"F")
if(z==2):
i=int(input("Enter value in F :"))
l= (2457+5*i-160)/9
print (l,"F")
if(z>2) or (z<1):
print("Wrong choice !! Retry")
if(b==3):
print("Press 1 for K - C; Press 2 for F - C")
z=int(input("Enter choice:"))
if(z==1):
k=int(input("Enter value in K :"))
h=k-273
print (h,"C")
if(z==2):
i=int(input("Enter value in C :"))
l=i+273
print (l,"K")
if(z>2)or(z<1):print("Wrong choice !! retry")
if(b>3) or (b<1):
print("Wrong choice !! retry")
if(a==2):
print("Press 1 for cm - inch ; Press 2 for inch - cm")
q=int(input("Enter choice: "))
if (q==1):
cm=int(input("Enter value in cm :"))
inch=2.5*cm
print( inch ,
"inch")
if (q==2):
inhc=int(input("Enter value in inch :"))
mc=10*inhc/25
print(mc)
if(q>2) or (q<1):
print("Wrong choice !! Retry")
if(a==3):
print("Press 1 for mile - km ; Press 2 for km - mile")
w=int(input("Enter choice:"))
if (w==1):
mile=int(input("Enter value in mile :"))
km=(25*mile)/29
print(km)
if (w==2):
km=int(input("Enter value in km :"))
mk=116*miel/100
print(miel)
if(w>2) or (w<1):
print("Wrong choice !! Retry")
if(a>3) or (a<1):
print("Wrong choice !! Retry")
print ("Answers given may be rounded off")
Download CODES here.
CLICK HERE for online Python.
Comments