Hi, Please, Need help for Lab and report in Python Script in Code, and it should
ID: 638242 • Letter: H
Question
Hi,
Please, Need help for Lab and report in Python Script in Code, and it should work in python 3.4.2 shell idle.
Overview
You will create a program that converts height values. In the standard (normal, successful completion) version will also ask the user for a height in centimeters as well and print out the height in inches.
Educational objectives
Gather information from the user
Perform mathematical calculations
Display results to specified accuracy
Standard version
Adjust the echoed height in feet and inches.
Ask for a second height in centimeters and convert it to feet and inches.
The program will still assume that the user input is accurate. If unexpected values are entered, the behavior of the script is "undefined".
Adjust the Echoed Height in Feet and Inches
Standard version
The full program run:
Please enter the height to be converted.
First, enter the feet: 6
Now, enter the inches: -2
your height is 5 feet 10 inches, or 70 inches. That is 177.80 cm.
Please enter a second height to be converted.
Enter the height in centimeters: 175
your height is 175 cm, or 68.898 inches.
Please note: The script first asks for integer feet, then integer inches, finally integer centimeters. The first two values work together to provide the first height value, in feet and inches. The third input value is the second height value, in centimeters.
Report
In addition to the Python script, the assignment includes a brief written report that answers the following questions:
How did you approach (get started with) this assignment?
How did you test your program?
What works and what don
Explanation / Answer
print("Please enter the height to be converted. ",end=" ");
feet = int(input())
print("First, enter the feet: ",end=" ");
inch = int(input());
if (inch < 0):
print('Your height is '+str(feet-1)+' feet '+str(12+inch)+' inch, or '+str((feet-1)*12+(12+inch))+' inch.'+' That is '+str(2.54*((feet-1)*12+(12+inch)))+' cm.')
else:
print('Your height is '+str(feet)+' feet '+str(inch)+' inch, or '+str((feet)*12+(inch))+' inch.'+' That is '+str(2.54*((feet)*12+(inch)))+' cm.')
print("Please enter a second height to be converted. ")
print("Enter the height in centimeters: ",end=" ");
h = int(input());
print("Your height is "+str(h)+', or '+str(format(h/2.54,'.3f'))+' inches ');
Report :
The Assignment is simple and we first took the input from the terminal
make 2 cases
if (inch < 0):
in this case we have reduce the feet by 1 as in example and to convert feet inot inch we multiple it by 12. to get positive inch we minus the input inch fom 12.
else:
feet and inch remains the same.
for centimeter to inch we divide by 2.54.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.