Python Format Exercises
Let’s check out some exercises that will help you understand .format() method better.
Exercise 1-a: Python format method of strings
Place a curly bracket "{}" in the appropriate place and fill inside .format()'s parenthesis so that "Hello!, Name" is printed.
Exercise 1-b: Format method to type a number
Using a string and .format() method print the number: 1 only.
Exercise 1-c: Format method to fill multiple values
Now using a string and .format() method and three curly brackets, print the numbers: 1, 2, 3 each separated with a comma.
Exercise 1-d: Format method for multiple values (more meaningful example)
Fill in the values for months, weeks and days accordingly.
Exercise 1-e: Format method w/ value position mapping
You can also use indexing inside your curly brackets so that you will decide the position instead of a default order.
By filling inside the curly brackets, make sure each bracket is matched to the appropriate value.
Exercise 1-f: Mapping exam scores with Format method
Fill inside .format()'s parenthesis so that it matches the correct values.