Python Playground
Print in a Function & String Formatting
Learn how to use print() inside a function and how to format strings in Python using f-strings, .format(), and % formatting.
Run the code first so AI Tutor can see the latest output or error.
Python Playground
Print in a Function & String Formatting
Learn how to use print() inside a function and how to format strings in Python using f-strings, .format(), and % formatting.
Run the code first so AI Tutor can see the latest output or error.
Python Playground
Print in a Function & String Formatting
Learn how to use print() inside a function and how to format strings in Python using f-strings, .format(), and % formatting.
Run the code first so AI Tutor can see the latest output or error.
Python Challenge
Draw a Grid with Print
Write a function called draw_grid that prints a 2×2 grid that looks exactly like this:
+ - - - - + - - - - + | | | | | | | | | | | | + - - - - + - - - - + | | | | | | | | | | | | + - - - - + - - - - +
Hints:
- To print more than one value on a line, use a comma-separated sequence:
print('+', '-') - By default,
printmoves to the next line. To stay on the same line, useend=' ':print('+', end=' ')print('-') - Think about which lines repeat — can you use a loop?
Run the code first so AI Tutor can see the latest output or error.
Hints
Reference Solution
