We've covered a lot, including if
/elif
/else
, logical operators (and
, or
, not
), and nesting conditions!
Engagement Message
Ready to learn a neat trick for displaying information and practice combining concepts?
Often, we want to print messages that include variable values, like "Your score is 95". Manually combining strings and numbers can be tricky. Python offers f-strings (formatted string literals) to make this easy!
Engagement Message
Ever heard of this before?
Using f-strings is simple! Just put an f
before the opening quote of your string. Then, inside the string, place any variable name within curly braces {}
. Python automatically inserts the variable's value.
Example: score = 100; print(f"Final score: {score}")
Engagement Message
What do you expect this code to print?
F-strings shine inside conditional statements, making your output dynamic and clear.
