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 Sequence | Description | Code |
|---|---|---|
| \n | New line | print('Father's \n name.') |
| \t | Tab - prints four spaces | print("Hi \t there!") |
| \b | Beep sound | print("John \bSmith") |
| \f | Backspace | print("Hello\fWorld") |
| \r | Form feed | print("Hello\rWorld") |
| \ooo | Carriage return | print("\110\145\154\154\157") |
| \xhh | It adds backslash | print("\x48\x65\x6c\x6c\x6f") |
| \' | Single quote | print("John\'s Car") |
| \" | Double quote | print("\"John Smith\"") |
| \\ | Null character | print("\\") |
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