Streamline Your Prints (Exercise)
In this exercise, you’ll get to streamline your prints. Like you saw before, just concatenating them might get a little clunky. So here you’ve got an exercise where you can try three different types of displaying the same string using different ways of assembling the string: concatenation,
str.format(), and also using an f-string.
The task is to create a float object named
weight with the value of
0.2, and then create a string object named
animal with the value
"newt", and then use these objects to print the following string.
So first, only using concatenation, the string should say
is the weight of the newt. And then you should display the same string using the
.format() method and empty curly bracket placeholders.
Become a Member to join the conversation.