Coursera Google Python Automation Course

From rbachwiki
Revision as of 16:21, 1 September 2020 by Bacchas (talk | contribs) (→‎Back To Top - Category)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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))

Back To Top - Category