Printing Output

To print something on screen, we have to write a simple expression.

Expressions

An expression is a piece of code that produces a value. When interpreter executes an expression, it will evaluates the code that we put in parenthesis.

For example, print("Hello World!") will produce Hello World! and print it on screen.

This expression will produce Hi 5 times on screen.

Escape Sequences

Escape SequenceDescriptionCode
\nNew lineprint('Father's \n name.')
\tTab - prints four spacesprint("Hi \t there!")
\bBeep soundprint("John \bSmith")
\fBackspaceprint("Hello\fWorld")
\rForm feedprint("Hello\rWorld")
\oooCarriage returnprint("\110\145\154\154\157")
\xhhIt adds backslashprint("\x48\x65\x6c\x6c\x6f")
\'Single quoteprint("John\'s Car")
\"Double quoteprint("\"John Smith\"")
\\Null characterprint("\\")

Practice Exercises

Complete these exercises to reinforce your learning and earn XP

Sign in to track your progress and earn XP!
Exercise 1 of 2Easy

Which of the following is a best practice in programming?

10 XP~2 min
Exercise 2 of 2Easy

Code that is easy to read and understand is called ___ code.

10 XP~2 min