in this class we discuss understanding output format in python
0:00 intro
0:22 examples strings
0:52 formatted strings examples
1:34 Format specifiers
Welcome, Wisdomers! Today, we are going to understand Output Formatting in Python.
This is a very easy class, but it is incredibly important when it comes to solving placement questions. Let’s break it down and understand it by looking at some practical examples.
Take a look at the following code
the first print function display a string hello.
the second print function. we displayed a string followed by a variable. we use comma to separate them.
the output is hello 10
take a look at the third print function and guess the output.
point to understand separate them with comma and we can write expressions also
lets understand the latest formatted string literals.
take a look at the following code
the first print statement contains string.
in side the string if you want to display variables or expressions we use flower brackets.
take a look at the character f before string quotations. its compulsory then only python apply formatted string literal rules.
take a look at the second print statement we used expression age+1 inside the string using flower brackets.
Beyond basic variable substitution, Python’s f-strings allow for precise control over how numbers are displayed using format specifiers
In our first example, we use the specifier .2f. The f stands for "fixed-point notation," and the .2 instructs Python to limit the display to exactly two decimal places.
An important technical detail to observe is that Python automatically applies rounding logic. In this case, the value 0.998 is rounded to the nearest cent, resulting in an output of $20000.00
In the second print statement, we use the specifier 10.2f. Here, the number 10 represents the total field width.
This tells Python to reserve a block of 10 character spaces for the number. Since our formatted value (20000.00) consists of only 8 characters including the decimal point. Python places two empty spaces before the number.
Finally, let’s look at the 010.2f specifier. By adding a leading 0 before the width, we instruct Python to fill any empty spaces with zeros instead of whitespace. take a look at the output.
we encourage you to practice these codings for deeper understanding.
visit our learning agent at www.wisdomers.in for quizzes and projects
In questa pagina del sito puoi guardare il video online Understanding Output Format in Python || Lesson 30 || Python For Beginners || della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Wisdomers - Placements & Programming 06 luglio 2026, condividi il link con amici e conoscenti, su youtube questo video è già stato visto No volte e gli è piaciuto 0 spettatori. Buona visione!