+ 1

41.2 Practice Help - From Feet to inches

Problem: You need to make a function that converts a foot value to inches. 1 foot has 12 inches. Define a convert() function, that takes the foot value as argument and outputs the inches value. —————— Lost here again as it doesn’t explain well how to set and use the convert variable in the lesson. Code: feet = int(input()) def convert(feet) print(feet/12) print(feet) Thanks!

2nd Apr 2021, 2:15 AM
Zach Z
12 odpowiedzi
+ 10
feet = int(input()) def convert(ft): inches = ft * 12 print(inches) convert(feet)
4th Apr 2021, 11:04 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Your convert function should multiply the number of feet passed to it by 12 and output that value. Remove the print(feet) and replace it with a call to the convert function passing the feet variable to it.
2nd Apr 2021, 2:50 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Zach Z When you call the convert() function you pass the value of the variable feet to the function. That value is held in the local function variable ft. The function definition is the part that starts with def and includes all the indented body. A function call is when you want to invoke that method by using its name followed by any required or optional arguments within parentheses. convert(feet) # function call You can call a function as many times as needed throughout your program.
9th Apr 2021, 6:59 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
THIS IS CORRECT,GUYS import java.util.Scanner; public class Main{ static void convert(double foot) { double inch = foot * 12; double num = inch; System.out.println(num); } //your code goes here public static void main(String[] args) { Scanner sc = new Scanner(System.in); double num = sc.nextDouble(); convert(num); } }
6th Oct 2024, 3:12 PM
BAMIGBAYE IBUKUNOLUWAPO
BAMIGBAYE IBUKUNOLUWAPO - avatar
+ 1
feet = int(input()) def convert(feet, inches): print (feet * inches) convert(feet, 12) this is the best, try it. it is working perfect
19th Jun 2021, 7:05 PM
Hugues Rodrigue Tha Andela
Hugues Rodrigue Tha Andela - avatar
0
ChaoticDawg little more guidance please. Still lost. Call to convert function?
4th Apr 2021, 9:42 PM
Zach Z
0
Thanks ChaoticDawg !! Curious, how does it know ft and feet are the same? I understand ft is short for feet but wouldnt that need to be stated for the code to understand? Thanks!
9th Apr 2021, 3:51 PM
Zach Z
0
def convert(feet): print(feet*12) feet = int(input()) convert(feet)
18th Feb 2022, 2:46 AM
Nathan Adam
Nathan Adam - avatar
0
foot = int(input()) def convert(): print(foot*12) convert()
16th May 2022, 8:57 AM
Junior Jackson
Junior Jackson - avatar
0
feet = int(input()) def convert(feet): print(feet*12) convert(feet)
9th Aug 2022, 2:01 PM
Abdul Ghafar
Abdul Ghafar - avatar
0
feet = int(input()) def convert(a): print(12 * a) convert(feet)
17th Nov 2022, 3:41 PM
Dinka Malcheva
Dinka Malcheva - avatar
0
In Java import java.util.Scanner; public class Main{ static void convert(double foot) { double inch = foot * 12; double num = inch; System.out.println(num); } //your code goes here public static void main(String[] args) { Scanner sc = new Scanner(System.in); double num = sc.nextDouble(); convert(num); } }
16th Mar 2024, 1:32 AM
Tony