HW2
1.Notebook
2.
4.寫1個程式需附加說明 Create a README For Github
```markdown
📌 Project Description
This simple Python program reads the distance between any two cities in Kilometers (Km) and automatically converts and displays it in meters (m), centimeters (cm), and miles.
🎯 Features
* Accepts user input for distance in Kilometers.
* Converts Kilometers into Meters, Centimeters, and Miles in real-time.
* Displays formatted output, including rounding the miles to two decimal places.
💻 Python Code
distance = int(input('Please Enter the distance(Km) between two cities:'))
meter = distance * 1000
centimeter = distance * 100000
miles = distance * 0.6213
print('Distance :', distance)
print(' Meter: ', meter)
print(' Centimeter: ', centimeter)
print(' Miles: %.2f' % (miles))
📊 Example Output
Please Enter the distance(Km) between two cities: 10
Distance : 10
Meter: 10000
Centimeter: 1000000
Miles: 6.21
🧮 Calculation
* **Meters:** $\text{Meter} = \text{Distance in Km} \times 1000$
* **Centimeters:** $\text{Centimeter} = \text{Distance in Km} \times 100000$
* **Miles:** $\text{Miles} = \text{Distance in Km} \times 0.6213$
Example for 10 Km:
* $\text{Meter} = 10 \times 1000 = 10000$
* $\text{Centimeter} = 10 \times 100000 = 1000000$
* $\text{Miles} = 10 \times 0.6213 = 6.21$
🚀 How to Run
1. Install Python 3 on your local system.
2. Save the code into a Python file named `distance_converter.py`.
3. Open terminal or command prompt, navigate to the directory and run:
```bash
python distance_converter.py
```
4. Enter the distance in Kilometers and view the converted values.
📚 Learning Objectives
This project helps beginners understand:
* Python variables and basic types
* Accepting console user input using `input()`
* Converting data types using `int()`
* Performing basic math calculations in Python
* Formatted string printing using `%f` formatting
🛠️ Technologies Used
* Language: Python 3
* Editor: Google Colab / Visual Studio Code
* Level: Beginner
📝 Conclusion
This project demonstrates how easily Python can perform units of measurement conversion. Through this exercise, I learned how to work with inputs, execute multiple numeric conversions, and output clean formatted strings.










留言
張貼留言