LITERALS AND IDENTIFIERS IN PYTHON

SAIROSHNI


 Literals

Literals can be defined as data that is given in a variable or constant. The values can be a number, character, string or boolean values.

There Are Five Types of Literals:

  • Numeric literals
  • string literals
  • boolean literal
  • special literal
  • literal collection

Numeric Literal:

Numeric literal are immutable(can't be changed) and it can be  an integer , float and complex values.

Example:

       x=156
       y=100.456

String Literal:

String literal are enclosed with in quotes.we can use either single or double.

Example:

       'hi','''welcome''

Boolean Literal:

Boolean literal can have only two values either true or false.

Special Literal:

Python has only one special literal called ''none''.

Literal Collection: 

Literal collection segment to specify values for a collection data type.

Identifiers:

An identifiers  is any name given to program element such as variables, functions, class ,variables modules or object.in python identifiers may contain letters, digit and underscore but it should not begin with numbers.

Rules For Using Python Identifiers:

  • An identifier name should not be a keyword.
  • An identifier name can begin with a letter or an underscore only.
  • An identifier name can contain both numbers and letters along with the underscore(A-Z, 0-9,_)
  • An identifiers name in python is case-sensitive .



More topic in Python

Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send