Show a Percentage (Solution)
00:00
When you divide 2
by 10
, you get a floating-point number with one decimal digit. You can format this as a percentage by using the percent sign as the format specification.
00:15 If you’ve been following along, then you can guess how to request zero decimal places. That’s right, you prepend a dot and a zero to the percent sign. You can use the same syntax in an f-string literal for a more compact syntax.
00:35 Okay, while this exercise wasn’t too difficult, it’s time to move on to another section of this course, in which you’ll interact with the user.
Become a Member to join the conversation.