Lesson 1: .format()

Format method is applied to strings and it makes formatting a breeze in different situations. Sometimes it can be used for decimal formatting, sometimes it can be used with place holders or fillers represented with curly brackets {}.

This allows you to create more complicated strings and place independent variables inside the string very conveniently.

Function 1: .format()

.format() function is a built-in Python method that can be very useful to create formatted versions of values such as strings and numbers.

Used Where?

Python’s .format() method is used to format Python strings and it’s applied on Python string to: 
  • Coveniently placing values or variables in string
  • Formatting numbers.

Syntax do(s)

1) One use of format function is using it after strings while including curly brackets: {} inside the string. i.e.:

"{} {}".format("Hello ", "World!")

Syntax don't(s)


Example 1

>>> my_message = “Jess and Jack will marry on {}”
>>> wed_date = “May 20”
>>> print(

[“Jess and Jack will marry on May 20”]

Value inside format’s parenthesis replaces the curly brackets in the string it’s applied on.

Example 2

.format() method can be even more useful with multiple values that needs to be placed in the string.

>>> user_message = “Baseball weighs {}, American football weighs {} and Basketball weighs {}”
>>> print(user_message).format(“5 oz.”, “15 oz.”, “22 oz.”)

“Baseball weighs 5 oz., American football weighs 15 oz. and Basketball weighs 22 oz.”


1- n/a


Advanced Concepts (Optional)

1- n/a

Lesson 2


Edward Moran ships at sea

Edward Moran

Ship at Sea

Ship at Sea by Edward Moran

“Have you installed Python yet?”

Having Python setup on your computer can expedite the learning experience and help you gain the real life skills in a non-simulation environment. Installing Python can have different nuances that can be confusing for everyone. We compiled a complete tutorial about the best and most convenient Python installing practices Check it out by clicking the button below.
Sandra Files