Skip to content

Instantly share code, notes, and snippets.

@TheMuellenator
Last active March 16, 2023 17:44
Show Gist options
  • Save TheMuellenator/fc9f7ffb3075da52a5953f859e01aee0 to your computer and use it in GitHub Desktop.
Save TheMuellenator/fc9f7ffb3075da52a5953f859e01aee0 to your computer and use it in GitHub Desktop.
Python Functions Coding Exercise - Part 2 Solution
# TODO 1: Add two parameters (length_ft and width_ft)
def calc_square_meters_from_feet(length_ft, width_ft):
# TODO 2: Modify the code below:
metric_length = length_ft * 0.3048
metric_width = width_ft * 0.3048
metric_area = metric_length * metric_width
# Leave the line below as it is
return metric_area
@lamfeto12
Copy link

image

@jurassicperx
Copy link

def calc_square_meters_from_feet(length_ft, width_ft):
print(length_ft * width_ft * 0.3048)

@Cynosure11
Copy link

My version of this code

TODO 1: Add two parameters (length_ft and width_ft)

def calc_square_meters_from_feet():
legnth_ft = float(input("what is legnth_fit?")) * float(0.3048)
widht_ft = float(input("what is width_ft?")) * float(0.3048)
square_feet = float(legnth_ft) * float(widht_ft)
metric_area = square_feet
# Leave the line below as it is
return metric_area
calc_square_meters_from_feet()

@farhanalifianto
Copy link

ez and simple
def calc_square_meters_from_feet(lft,wft):

# TODO 2: Modify the code below:'
lft= lft * 0.3048
wft= wft * 0.3048
metric_area = lft * wft





# Leave the line below as it is
return metric_area

@Lexeuz
Copy link

Lexeuz commented Dec 11, 2022

This is my solution:
def calc_square_meters_from_feet(length_ft, width_ft): return round(((length_ft * width_ft) * 0.3048) * 0.3048, 4)

@catalinazz
Copy link

catalinazz commented Mar 10, 2023

I added a round() and now it is accepted

def calc_square_meters_from_feet(length_ft, width_ft):

# TODO 2: Modify the code below:
metric_area = 0
metric_area= length_ft*0.3048*width_ft*0.3048
metric_area= round(metric_area,4)
# = the line below as it is
return metric_area

@Ayush0901
Copy link

@catalinazz that's good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment