Merge branch 'master' of ssh://86thumbs.net:3022/waldek/python_course_doc
This commit is contained in:
commit
c74462e082
|
@ -1,4 +1,4 @@
|
||||||
# Basic placeholders
|
# Basic placeholders usage
|
||||||
|
|
||||||
ingredient = "sugar"
|
ingredient = "sugar"
|
||||||
quantity = "500g"
|
quantity = "500g"
|
||||||
|
@ -8,7 +8,24 @@ ingredient_string = "- {}: {}".format(ingredient, quantity)
|
||||||
print(ingredient_string)
|
print(ingredient_string)
|
||||||
|
|
||||||
|
|
||||||
# Named placeholders
|
|
||||||
|
|
||||||
|
# Indexed placeholders usage
|
||||||
|
#
|
||||||
|
# Placeholders are identified by index number, 0 being the first parameter passed
|
||||||
|
|
||||||
|
|
||||||
|
name = "John"
|
||||||
|
age = 30
|
||||||
|
|
||||||
|
greetings = "My name is {0}, i'm {1}.".format(name, age)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Named placeholders usage
|
||||||
|
#
|
||||||
|
# Placeholders are identified by name, order doesn't matter
|
||||||
|
|
||||||
fname = "John"
|
fname = "John"
|
||||||
lname = "Doe"
|
lname = "Doe"
|
||||||
|
@ -16,3 +33,8 @@ lname = "Doe"
|
||||||
bond_string = "My name is {lastname}, {firstname} {lastname}".format(firstname=fname, lastname=lname)
|
bond_string = "My name is {lastname}, {firstname} {lastname}".format(firstname=fname, lastname=lname)
|
||||||
|
|
||||||
print(bond_string)
|
print(bond_string)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue