28.9k views
3 votes
Define a function print_total_inches, with parameters num_feet and num_inches, that prints the total number of inches. Note: There are 12 inches in a foot. Sample output with inputs: 58 Total inches: 68 def print_total_inches (num_feet, hum_inches): 2 str1=12 str2=num_inches 4 print("Total inches:',(num_feet*strl+str2)) 5 print_total_inches (5,8) 6 feet = int(input) 7 inches = int(input) 8 print_total_inches (feet, inches)

User JNL
by
4.4k points

2 Answers

2 votes

Answer:

Written in Python:

def print_total_inches(num_feet,num_inches):

print("Total inches: "+str(12 * num_feet + num_inches))

feet = int(input())

inches = int(input())

print_total_inches(feet, inches)

Step-by-step explanation:

User Florian Bach
by
4.7k points
5 votes

I'll pick up your question from here:

Define a function print_total_inches, with parameters num_feet and num_inches, that prints the total number of inches. Note: There are 12 inches in a foot.

Sample output with inputs: 5 8

Total inches: 68

Answer:

The program is as follows:

def print_total_inches(num_feet,num_inches):

print("Total Inches: "+str(12 * num_feet + num_inches))

print_total_inches(5,8)

inches = int(input("Inches: "))

feet = int(input("Feet: "))

print_total_inches(feet,inches)

Step-by-step explanation:

This line defines the function along with the two parameters

def print_total_inches(num_feet,num_inches):

This line calculates and prints the equivalent number of inches

print("Total Inches: "+str(12 * num_feet + num_inches))

The main starts here:

This line tests with the original arguments from the question

print_total_inches(5,8)

The next two lines prompts user for input (inches and feet)

inches = int(input("Inches: "))

feet = int(input("Feet: "))

This line prints the equivalent number of inches depending on the user input

print_total_inches(feet,inches)

User Dalin Huang
by
4.5k points