Skip to content

Instantly share code, notes, and snippets.

@EmmanuelKasper

EmmanuelKasper/bmi.py

Last active Dec 25, 2019
Embed
What would you like to do?
Different line joinings in pyton
#!/usr/bin/python3
def output():
# explicit line joining with backslash (prefered for simple strings)
print("let's do some calculations \
of the body mass index")
# explicit line joining with operator # generally prefered, allows to keep indentation consistent
# PEP 8 recommends operator on the next line
print(f"weight: 75, size: 1.77 "
+ f"bmi: {bmi_calc(75,1.77)}")
# implicit line joining
# Expressions in parentheses, square brackets or curly braces
# can be split over more than one physical line without using backslashes
def bmi_calc(weight,
height):
return weight / height**2
output()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment