Computer Science

One foot equals 12 inches. Write a function that accepts a length written in feet as an argument and returns this length written in inches. Write a second function that asks the user for a number of feet and returns this value. Write a third function that accepts a number of inches and displays this to the screen. Use these three functions to write a program that asks the user for a number of feet and tells them the corresponding number of inches.

Python

Python Funda

25 Likes

Answer

def feetToInches(lenFeet):
    lenInch = lenFeet * 12
    return lenInch

def getInput():
    len = int(input("Enter length in feet: "))
    return len

def displayLength(l):
    print("Length in inches =", l)

ipLen = getInput()
inchLen = feetToInches(ipLen)
displayLength(inchLen)

Output

Enter length in feet: 15
Length in inches = 180

Answered By

13 Likes


Related Questions