๐Ÿ–จ๏ธ Print Function

4th Grade ๐Ÿ’ป Coding

`print` is a built-in Python function that shows on the screen whatever you put inside its parentheses: text, a number, a variable or the result of a calculation.

Free ยท US Letter ยท no sign-up
Google Classroom Save to Pinterest Email me

print("Hello, world!") shows text, and text always goes in quotation marks. print(2 + 3) shows 5: numbers go without quotes, and Python does the math before it shows the result. print(name) shows the value stored in the variable name. You can also print several values separated by commas, like print("Age:", 11), and Python puts a space between them.

Despite its name, print doesnโ€™t send anything to a printer. The word is left over from the days when computer output really was printed on paper. print is also the simplest debugging tool there is: you add it to see values in the middle of your program.

For example

  • print("5" + "5") shows 55, but print(5 + 5) shows 10.
  • Ava added print(i) inside a loop to see how many times it ran.
  • print("Age:", 11) shows โ€œAge: 11โ€, because Python adds a space between the values.

๐Ÿ“Œ Remember: print = โ€œshow it on the screen.โ€ Text in quotes, numbers without.

Quick quiz

  1. What does print do in Python?

  2. What will print(2 + 3) show?

  3. How do you write text inside print?

๐Ÿ”Ž Ask Thinkapedia another question