print('I love the %s language' %'python')
print('I %s the %s language' %('love', 'python'))
feeling = 'love'
language = 'python'
print('I %s the %s language' %(feeling, language))
print('I %s the %r language' %(feeling, language))
print('I \t %s \t the %r language' %(feeling, language))
print('I give python a rating of %s' %(9.5))
print('I give python a rating of %d' %(9.5))
# %5.2f
# 5 = min # chars string should contain (whitespace added if needed)
# .2f = decimal places
print('I give python a rating of %2.1f' %(9.5))
print('I give python a rating of %2.10f' %(9.5))
print('I give python a rating of %10.1f' %(9.5))
print('I give python a rating of %2.15f' %(9.5))
print('We will %s %d times'%('try', 99))
print('I need to learn {}'.format('formatting'))
ratings = [5,7,9]
print('I rate python {}'.format(ratings[2]))
adjective = 'cool'
print('The language {2} {1} {0}'.format(adjective,'is','python'))
print('{p} is a snake and {p} is a language.'.format(p='python'))
print('{0:8} | {1:9}'.format('Name', 'Rating'))
print('{0:8} | {1:9}'.format('Python', 10))
print('{0:8} | {1:9}'.format('SQL', 9))
print('{0:<8} | {1:^8} | {2:>8}'.format('Left','Center','Right'))
print('{0:<8} | {1:^8} | {2:>8}'.format("I'm",'so','aligned'))
print('{0:=<8} | {1:-^8} | {2:.>8}'.format('Left','Center','Right'))
print('{0:=<8} | {1:-^8} | {2:.>8}'.format("no", "blanks", "allowed"))
print('Sliiiiiide to the right:%10.2f' %99.99)
print('Sliiiiiide to the right:{0:10.2f}'.format(99.99))
name = 'sikka sikka Slim Shady'
print(f"My name is {name}.")
name = "Prince"
print(f"I am the artist formerly known as {name!r}")
num = 8.0001
print("My 10 character, four decimal number is:{0:10.4f} ... which is how much sleep I need".format(num))
print(f"My 10 character, four decimal number is:{num:{10}.{6}} ... which is how much sleep I need")
num = 8.0000
print("My 10 character, four decimal number is:{0:10.4f} ... which is how much sleep I need".format(num))
print(f"My 10 character, four decimal number is:{num:{10}.{6}} ... which is how much sleep I need")
num = 8.0001
print("My 10 character, four decimal number is:{0:10.4f} ... which is how much sleep I need".format(num))
print(f"My 10 character, four decimal number is:{num:10.4f} ... which is how much sleep I need")