Practice Printing with .format() - 18.10 | 18. PRINT | CBSE 9 AI (Artificial Intelligence)
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Printing with .format()

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.

Learning

Practice Questions

Test your understanding with targeted questions

Question 1 Easy

Use .format() to create a sentence: 'I like' + favorite_fruit

💡 Hint: Remember to use {} as a placeholder for favorite_fruit.

Question 2 Easy

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

Question 1

What does the .format() method do?

Joins strings directly
Replaces placeholders with values
Adds numbers together

💡 Hint: Think about how values are injected into a string.

Question 2

True or False: The .format() method can only take one argument.

True
False

💡 Hint: Recall examples with multiple variables.

2 more questions available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

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.

Challenge 2 Hard

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.