Wednesday, June 12, 2013

Learn Python the hard way 6-10

So time for some more learn python the hard way.

Ex6: more variables that can be used in place of long strings. so instead of typing the same message over and over again you can just set it to a variable and drop it where it is needed in the code.

x = "you can't go that way"
y = "sup my home skillet %s"

print x
you can't go that way

print y % x
sup my home skillet you can't go that way

print x + y % x
you can't go that way sup my home skillet you can't go that way

Ex7: added more expressions to stings and variables for instance

print "x" * 10
you will get "xxxxxxxxxx"

this can be useful for dividers

Ex8-10: just more examples of formatting and variables as well as showing the triple quotes ~

No comments:

Post a Comment