
Learning outcomes
By the end of this chapter, you should be able to:- define literal and variable clearly
- identify numeric, string, boolean, and special literals
- write valid escape sequences in strings
Variable vs literal
- Variable: name that stores a value
- Literal: fixed value written directly in code
xis variable25is literal
Types of literals
Numeric literals
String literals
Boolean literals
Special literal
None means no value / null reference.
Escape sequences in strings
\n, \t, \", \\
Exam-focused points
- literals are constants directly written in source code
True,False, andNoneare keywords- string literals can use single or double quotes
Practice questions
- Classify these as variable or literal:
x,99,"hi",False. - Write one example each of int, float, bool, and None literal.
- Print this exact output using escape sequences:
