[Type A] Python Revision Tour-1 – Chapter 1

|
Table of Contents

3. What are literals in Python? How many types of literals are allowed in Python?

Literals are raw, unprocessed data that you can directly insert into your program. They come in different types, each suited for a specific purpose:

  • Numeric Literals: These can be integers, numbers with decimals called float literals, or even complex numbers.
  • String Literals: Anything you can write, from single words to entire paragraphs, can be stored as text or string literals. You can use single quotes (‘text’), double quotes (“text”), or even triple quotes (“””text”””) to define them. Triple quotes are especially useful for longer pieces of text or including special symbols.
  • Boolean literals: Boolean represents whether something is true or false. This helps your program make decisions based on conditions. Imagine a light switch: “on” is like True, and “off” is like False.
  • Special Literals: The “None” literal acts like an empty box, indicating that no information is currently stored in that spot.
"Spread the light within, illuminate the hearts around you. Sharing is not just an action, but a sacred journey of connecting souls."~ Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *