Functions and print

In life we frequently need to ask something to do something. For example, at a restaurant, we ask to be seated. Some stuff happens, resulting in…we are given a seat.

Functions are like that…ask the seat_me() function do to some work and come back with a table to sit at.

Code

print('I would like a seat')

Analysis

  • print is a function
  • It is a built-in function, included in Python
  • You give it a value…aka a function argument
  • It writes the function argument to output

Exercises

  • Print a number
  • Print…nothing (no argument)
  • Print two strings, separated by a comma
  • Trying printing print itself

Quiz

  • Is print a class or a function? How can you tell?
  • Does print take any arguments?
  • (Bonus) Does print return a value?
  • Do you have to import print? Why not? (Hint: first italics in Analysis)