livepython.net
CHAPTER 02The Print Function
2.6  PRACTICE

Python print() Practice Questions for Beginners

Chapter 2 Recap and Practice

You now know how to show almost anything on the screen. Here is the whole chapter in one table:

You writeIt does
print("text")shows text; quotes mark where it starts and ends
print(25)shows a number; numbers need no quotes
print("a", "b")shows several items with one space between them
print(5 + 3)calculates first, then shows the answer
\nstarts a new line inside text
\tjumps to the next tab stop, to line up columns
\' and \"print a quote inside text
\\prints one backslash
sep="-"changes what goes between the items
end=" "changes what comes after the last item
"""…"""text over many lines, with any quotes inside

And the three errors to look for first: missing quotes, missing brackets, and capital letters (Print instead of print).

Practice questions

Write each program yourself, press Run to try it, and Submit when it's ready. Start with the easy ones.

The print() function

  1. 13.Python Program to Print Multiple LinesEasySolve
  2. 2.Python Program to Print a Phone Number Without QuotesEasySolve
  3. 3.Python Program to Print a String and a Number TogetherEasySolve
  4. 4.Python Program to Print a Message and a Calculation in One LineEasySolve

Escape sequences

  1. 5.Python Program to Print Multiple Lines with One print()EasySolve
  2. 6.Python Program to Create a Name Card Using TabsEasySolve
  3. 7.Python Program to Print Nested Quotes with Escape CharactersEasySolve
  4. 14.Python Program to Print Escape Sequences as TextEasySolve
  5. 11.Python Program to Print a Digital ReceiptMediumSolve

sep and end

  1. 8.Python Program to Print Details Separated by CommasEasySolve
  2. 9.Python Program to Print One Line with Several print() CallsEasySolve
  3. 15.Python Program to Print a List with sep and endMediumSolve

Triple quotes

  1. 10.Python Program to Print Multiple Lines Without Escape SequencesEasySolve
  2. 12.Python Program to Print a Console DashboardHardSolve

Common errors

  1. 28.Fix the print() Errors in a Greeting ProgramEasySolve
  2. 29.Fix the print() Errors in a Receipt HeaderMediumSolve

You can now make Python say anything, in any shape. Next, you'll learn to think like a programmer.