Centimeter to Feet converter in Python -
i writing programme convert given value in centimeters both feet , inches. wrote 2 functions; 1 function converts value in centimeters feet , passes decimal part of value function converts decimal number inches. code shown below:
class="lang-python prettyprint-override">import math def feetconverter(number): tempinchvalue, feetvalue = math.modf(int(number) * 0.03281) inchconverter(tempinchvalue) #calls inch converter function homecoming feetvalue def inchconverter(tempinchvalue): finalinchvalue = tempinchvalue * 12 homecoming finalinchvalue print("enter height in centimeters: ") centimetervalue = input() print(feetconverter(centimetervalue))
the problem programme not given inches value - if inchconverter function not beingness called. appreciate corrections. give thanks you
a function can homecoming 1 value, you're printing homecoming value of feetconverter
, homecoming value of inchconverter
beingness ignored
def feetconverter(number): tempinchvalue, feetvalue = math.modf(int(number) * 0.03281) inchconverter(tempinchvalue) #calls inch converter function, , ignores homecoming value homecoming feetvalue # returns feetvalue only.
you should phone call & print inchconverter
separately:
print(inchconverter(centimetervalue))
alternatively, homecoming tuple
of values:
def feetconverter(number): tempinchvalue, feetvalue = math.modf(int(number) * 0.03281) homecoming (feetvalue,inchconverter(tempinchvalue))
python
No comments:
Post a Comment