Coding
Q1. Write a program that asks the user to enter a distance in kilometers, and then converts that distance to miles. The conversion formula is as follows:
Miles Kilometer x 0.6214
Submission for Q1:
- A Python code file
- Screenshot of the Running program
Q2. Write the following codes
Submission of Q2 (All parts a, b, and c):
- A summary of the program, what does program do
- Screenshot of the Running program
a). def message():
print('I am Arthur,')
print('King of the Britons.')
message()
Sample Answer
Q1:
Python code:
Python
def kilometers_to_miles():
kilometers = float(input("Enter a distance in kilometers: "))
miles = kilometers * 0.6214
print(kilometers, "kilometers is equal to", miles, "miles.")
kilometers_to_miles()
Description of execution:
- The program prompts the user to enter a distance in kilometers.
- It converts the input to a floating-point number and stores it in the
kilometers
variable.