๐จ๏ธ 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.
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, butprint(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
What does print do in Python?
What will print(2 + 3) show?
How do you write text inside print?