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()
Full Answer Section
- It multiplies
kilometers
by 0.6214 to calculate the distance in miles.
- It prints a statement displaying both the original distance in kilometers and the converted distance in miles.
Q2a:
Python code:
def message():
print("I am Arthur,")
print("King of the Britons.")
message()
Summary:
This program defines a function called message()
that prints two lines of text: "I am Arthur," and "King of the Britons." It then calls the message()
function to execute those print statements.
Description of execution:
- The
message()
function is defined.
- When called, it prints "I am Arthur," on a line by itself.
- It then prints "King of the Britons." on another line.
- The program ends.