Printing in Python with f-strings

Python Series | Post 3 Printing in Python We've learned about data types and variables. Now let's talk about how to actually see our results- printing in Python. There are different ways to print in Python, but the most convenient and widely used one is f-strings. Here's how it works: name = 'Rahul' score = 100 subject = 'Mathematics' print(f"Results are out! {name} scored {score} in {subject}.") Output: Results are out! Rahul scored 100 in Mathematics. Simple right? You write f before the inverted commas, type your sentence, and wherever you want a variable to appear, just put it inside { } ⚠️ Pro tip: If you forget the f at the beginning, Python won't substitute your variables. Your output will literally print: "Results are out! {name} scored {score} in {subject}." One small letter, big difference. f-strings are clean, readable and save you a lot of time, especially when working with large datasets as an analyst. What part of printing in Python confused you? Drop it below and I'll simplify it 👇 #Python #DataAnalytics #LearnPython #DataAnalyst #PythonForBeginners

To view or add a comment, sign in

Explore content categories