Let’s get started! 🔥🔥🔥 In this video, we will show you how to write a few PYTHON 🐍 scripts that demonstrate the use of the format() helper function in the string class that you’ll likely use when building real-world Python programs. A helper method is a function that’s available to values of a particular data type, and provides additional helpful functionality. In this lesson, you will learn some basics in less than 10 minutes! In this video, you will learn how to:
★ 0:18 Show the format() function’s merge feature using a series of replacement fields.
★ 5:40 Demonstrate the same functionality could be achieved, with less typing, by using “f-strings” – formatted string literals.
★ 7:56 Evaluate simple expressions by performing calculations with variables in the replacement field of an f-string.
★ 9:56 Use one of the format specifier syntax in replacement fields to control alignment and padding.
Tips and Tricks:
► Use f-strings if possible (available since Python 3.6). They are a great new way to format strings. Not only are they more readable, more concise, and less prone to error than other ways of formatting, but they are also faster because they are expressions evaluated at runtime rather than constant values!
► Even though we could perform calculations directly inside the replacement field. It is not recommended because it’s less readable than creating a temporary variable to perform the calculations instead.
► Format specifiers are a compact syntax that allows you to format numbers, dates, time, percentages, and exponents.
WANT MORE PYTHON TUTORIALS? 🐍
Python Coding for Beginners: https://www.youtube.com/playlist?list…