Difference between revisions of "Coursera Google Python Automation Course"

From rbachwiki
Jump to navigation Jump to search
(Created page with "==If statements== <pre> def convert_distance(dist, unit): # if(unit =="mile"): xtext=" The distance is " ml = dist / 1.6 m...")
 
Line 22: Line 22:
print(str(xme))
print(str(xme))
</pre>
</pre>
==[[#top|Back To Top]] - [[Python|Category]]==

Revision as of 22:20, 12 April 2020

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