Python Program to Convert Kilometers to Meters, Miles

Program to convert kilometers to meters, miles in Python; In this tutorial, you will learn how to convert km (Kilometers) to m(meters), miles in python.

Python Program to Convert Kilometers to Meters, Miles

Let’s use the following algorithm to write a python program to convert kilometers to meters, miles:

  • Python Program to Convert Kilometers to Miles.
  • Python Program to Convert Kilometers to Meters.
  • Python Program to Convert Kilometers to millimeter.

Python Program to Convert Kilometers to Miles

# Python program to convert kilometer to miles

# take input from user
kilometers = float(input("Enter value in kilometers: "))

# conversion factor
conMil = 0.621371

# calculate miles
miles = kilometers * conMil
print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))

Output

Enter value in kilometers:  100
100.00 kilometers is equal to 62.14 miles

Python Program to Convert Kilometers to Meters

# Python program to convert kilometer to miles

# take input from user
kilometers = float(input("Enter value in kilometers: "))

# calculate miles
meter = kilometers * 1000.0

print('%0.2f kilometers is equal to %0.2f meters' %(kilometers,meter))

Output

Enter value in kilometers:  2
2.00 kilometers is equal to 2000.00 meters

Python Program to Convert Kilometers to millimeter

# Python program to convert kilometer to millimeter

# take input from user
kilometers = float(input("Enter value in kilometers: "))

# calculate miles
millimeter = kilometers * 1000000

print('%0.2f kilometers is equal to %0.2f milimeters' %(kilometers,millimeter))

Output

Enter value in kilometers:  2
2.00 kilometers is equal to 2000000.00 milimeters 

Recommended Python Programs

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *