Part3- Python Fundamentals | Start from the basics
If u fell any difficulty in watching the content, try to reduce the size of this page or rotate your portable device if you are using it
In the previous article we learnt about some types of tokens. In this article, we shall continue to learn about different types of tokens.
3. Literals/Values: Literals (often referred to as constant Values) are data items that have a fixed value. Python allows several kinds of literals:
1. String literals 2. Numeric literals 3. Boolean literals 4. Special Literal - None 5. Literal Collections
i) String Literals: The text enclosed in quotes forms a string literal in Python. For example, 'a', 'xyz', "pqrs", etc. all are string literals. Unlike many other languages, both single character("a", 'x') as well as multiple characters("abc", "xyz") enclosed in quotes are treated as string literals.
*In Python, string literals can be declared under both single as well as double quotes, but not in triple quotes about which we shall learn afterwards.
Example: 'Vishnu', "friends", "SiStEr", '12345', "62996",etc.
Python also allows non-graphic characters as string literals(values); Non-graphic characters are those characters that cannot be typed directly from the keyboard i.e. backspace, tab, carriage return, etc. These non-graphic characters can be represented by using escape sequences. An escape sequence is represented by a backslash(\) followed by one or more characters.
The following table gives a listing of esquences:
String Types in Python
Python allows you to have two string types:
1. Single-line string
2. Multi-line string


No comments