18.10 - Printing with .format()
Enroll to start learning
You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Practice Questions
Test your understanding with targeted questions
Use .format() to create a sentence: 'I like' + favorite_fruit
💡 Hint: Remember to use {} as a placeholder for favorite_fruit.
What will this print: print('The answer is {}.'.format(42))?
💡 Hint: Identify what .format() is replacing inside the string.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What does the .format() method do?
💡 Hint: Think about how values are injected into a string.
True or False: The .format() method can only take one argument.
💡 Hint: Recall examples with multiple variables.
2 more questions available
Challenge Problems
Push your limits with advanced challenges
Write a function that takes a name and age, and returns a string formatted as 'Name: {name}, Age: {age}'. Use .format() for formatting.
💡 Hint: Think about how to plug the parameters into the string.
Given a list of scores, write code that outputs 'The scores are: score1, score2, score3' using .format() and unpack the list.
💡 Hint: Remember how to unpack a list in .format()!
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.