Flat_Eric Contemplating Data Type Conversions

Escape Sequence

Ctrl + Alt + Delete.... Just kidding, don't do that.

Escape Sequences

In the world of computers, "Escaping" means telling the system to stop what it's doing and look at a special command. In Python, we use the Backslash \ to escape the standard rules of a string. "Escape sequences are common across almost every programming language."

Basically what we are saying is anything that is immediately after the \ should be treated as a string. To use a ' or " we need to use \' and \", the same applies to a \, to tell Python we want the backslash to be seen as text we need to use \\.

Why do we need to escape?

Imagine you are typing a sentence and you want to start a new line, or you want to use a quote mark without Python thinking the string is finished. Python sees a string like a straight road—the backslash is the "exit ramp" that lets you do something different.

The Most Common "Exits"

In Python, the backslash \ is a special character. When you pair it with certain letters, it creates a "command" inside your string:

Escape Sequence

Python is literal. If you don't give it precise instructions, it crashes. Your goal is to figure out how to bypass Python's default string behavior.

The Objective

Input this exact line into the PyBox and get it to output without a SyntaxError:

it's not 'my' fault the "string" is not a int('string')

The Constraints

Time to experiment!

Coding Exercises (VS Code) Instructions:

Exercise 1:

The Objective

Produce this specific output using one print() statement.

Use \t to align the columns and \n for the rows.


Language    Level
Python      High
C++         Low
    

Exercise 2:

Path Integrity:

The Objective

Windows paths often break strings.

Print this path exactly:


C:\Users\node\temp
    

This course was built by DevSTEM - we turn teaching materials into interactive web courses like this one.

Build your own course