Coursera Google Python Automation Course
Jump to navigation
Jump to search
If statements
def convert_distance(dist, unit): # if(unit =="mile"): xtext=" The distance is " ml = dist / 1.6 mlr = int(ml) output = xtext + str(mlr) + " " + unit return output elif(unit=="km"): xtext=" is " km = dist * 1.6 kmr = int(km) output = str(dist) + " Miles" + xtext + str(kmr) + " " + unit return output xme = convert_distance(100, "km") print(str(xme))