Showing posts with label python conversion. Show all posts
Showing posts with label python conversion. Show all posts

Friday, 22 December 2017

Python Program to Convert Decimal to Binary, Octal and Hexadecimal


Code:

dec = int(input("Enter a decimal number: "))  
  
print(bin(dec),"in binary.")  
print(oct(dec),"in octal.")  
print(hex(dec),"in hexadecimal."  


Output:

Execute and get the Output.


More Python Programs:




















Python program to convert Celsius to Fahrenheit


Code:

# Collect input from the user  
celsius = float(input('Enter temperature in Celsius: '))  
  
# calculate temperature in Fahrenheit  
fahrenheit = (celsius * 1.8) + 32  
print('%0.1f  Celsius is equal to %0.1f degree Fahrenheit'%(celsius,fahrenheit))  


Output:

Execute and get the output.


More Python Programs:



















Python program to convert kilometers to miles


Code:

# Collect input from the user  
kilometers = float(input('How many kilometers?: '))  
# conversion factor  
conv_fac = 0.621371  
# calculate miles  
miles = kilometers * conv_fac  
print('%0.3f kilometers is equal to %0.3f miles' %(kilometers,miles))  


Output:

Execute and get the output.


More Python Programs:



















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...