Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    Python Program to Convert Kilometers to Miles

    Python Programming Examples


    This Python program converts kilometers to miles. It takes input from the user in the form of kilometers and performs simple arithmetic operations for the expected output.

    Program:

    #Taking user input
    km = float(input("Enter value in kilometers: "))
    
    #Conversion factor
    cf = 0.621371
    
    #Calculate miles
    miles = km * cf
    
    #Print the output
    print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))

    Program Output:

    Enter value in kilometers: 12
    12.00 kilometers is equal to 7.46 miles


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.