1. Write a Python script that asks the user to enter
a length in centimetres. If the user enters a
negative length, the program should tell the
user that the entry is invalid. Otherwise, the
program should convert the length to inches
and print out the result. There are 2.54
centimetres in an inch.
Answers
Answered by
0
Answer:
here is your Answer
Explanation:
mark me as brilliant and thank my all Answers
Attachments:
Answered by
1
Required Answer:-
Question:
- Write a Python script to convert length from centimeters to inches.
Solution:
Here comes the program.
n=float(input("Enter length in centimeters: "))
if n<0:
print("Invalid Input.")
else:
x=n/2.54
print(n,"centimeters =",x,"inches")
Algorithm:
- START.
- Ask the user to enter length in cm.
- If length is negative, display an error message or else, convert length from cm to inches and display the result.
- STOP.
See the attachment for output ☑.
Attachments:
Similar questions
Math,
2 months ago
Social Sciences,
2 months ago
Business Studies,
2 months ago
Science,
5 months ago
Political Science,
11 months ago
Social Sciences,
11 months ago