Screen output

In this chapter we will explor the print() function to write text to the screen.

Exercise 1

Which print statements are correct?

  • print("9" + "9")
  • print "nine"
  • print(str(9) + "nine")
  • print(9 + 9)
  • print(nine)

Exercise 2

Explain the following statement:

print("Emily\tSmith\n2000")

Exercise 3

Some babies have names similar to celebrities. Write a program producing the following output:

Harry      Hermione      Severus
Tyrion     Daenerys      Frodo
Luke       Leia          Darth

Exercise 4

Expand the previous exercise so that:

  • only a single print statement is used.
  • the names are stored in a variable before building the string.

results matching ""

    No results matching ""