Skip to main content

Character Set and Tokens in Python

 Character Set: Character Set in Python consist of  valid characters such as alphabets, digits or special characters that are recognized by the library of Python Language.

Alphabets:                    A,B,......Y,Z or a,b,.......y,z.

Digits:                         0,1,2,3,4,5,6,7,8,9

Special Character:     ~!@#$%^&*()_+{}[];:'"\,./<> etc.

White spaces   :          Blank space, new line, etc.

Token: The smallest individual unit in a program is referred as 'Token'. It is also called Lexical Element or Lexical Unit.

It can be categorized as:

1. Keywords: Keywords are the reserved words that has specific function in a program. These words are used while writing program to get desired output. The keywords are executed  as its purpose/action is already explained inside the language interpreter.

  • All Keywords are written in lower case.
  • Keywords are also called 'Reserved Words'.
  • There are 33 keywords in Python.

2. Identifiers: Identifiers are the fundamental building blocks of a program that are used to identify names of different elements of the program such as variable.

Guidelines for Creating Identifiers in Python:

  • An identifier is an arbitrary sequence of letters in lower case(a-z) & upper case(A-Z), digits(0-9) and underscore(_).
  • The First Character of the identifier must be a letter or underscore. It must not be start with digits(0-9).
  • An identifier must not be a 'keyword'.
  • An identifier must not contain any special character except underscore.

3.Puntuators: Puntuators are used as marks or as separators in a program. The characters used as puntuators are ' " # \ etc.

4. Literals: Literals are data items that never change their value during the execution of a program. These are commonly called constant. 

In Python there are four types of literals(constants):

  • Integer Literals: Integer literals are whole numbers without any fractional part. It may be positive or negative. ex- 2,5,1324,-145 etc.

  • Character Literals: Character literals refer to single character that is enclosed in a single quote. For example: 'A' ,'1' etc.
  • Floating Literals: Floating literals are fractional number. They may be positive or negative. Ex:12.234, -9.256 etc. 
  • String Literals: A string literal is a sequence of characters enclosed within pair of single or double quotes. Ex: 'AMIT', "Hello" etc.

5. Operator: Operators are tokens that does computation with designated or given values in an expression. Operators applied on operands form an expression.

Operand is the value or variable on which calculation is performed.

*Keep Learning * In Next Note I will Explain Operator*TQ

Comments

Post a Comment

Popular posts from this blog

Computer Generations

 Computer Generations   Computers have evolved over time through different generations, each marked by significant technological advancements and changes in design and architecture. These generations are often categorized based on the underlying hardware and the key developments that distinguish one Generation from another. Let's explore the main computer generations: First Generation Computers    The First Generation of computers refers to the initial period of electronic computing, characterized by the use of vacuum tubes as the primary electronic component. This Generation spans the 1940s and 1950s and is marked by groundbreaking developments in computer technology.  Examples of First-Generation Computers:  o ENIAC (Electronic Numerical Integrator and Computer): Completed in 1945, ENIAC was one of the first electronic general-purpose computers. It was designed to calculate artillery firing tables for the United States Army during World War ...

Computer Basic

  The word “computer” comes from the word “compute”, which means to calculate”. Charles Babbage is known as the ' Father of computer' .  A computer often referred to as a “data processor” because it can store, process, and retrieve data whenever desired.  The activity of processing data using a computer is called data processing.    Data processing consists of three sub activities:- (1)          Capturing input data (2)          Manipulating the data and (3)          Managing output results. Data : - Data is raw material used as input to data processing. Data can be anything like numerical, non-numerical or a mixture of both. Information : - Information is processed data obtained as output of data processing. Computer: - A computer is an electronic device which performs numerical calculation and logical calculation at hig...

Office Package and Features of Office Package

Most of the official jobs today are dependent on computers. Computer helps in accomplishing different types of official tasks with the help of 'Office Package'. With the help of 'Office Package ' to accomplish basic tasks like typing and composing letters, doing calculations and comparisons, manipulation data and generating multiple types of reports, making presentation for demonstration, seminars etc.   For example: MS Office, OpenOffice, etc. Office package includes the following applications: 1. Word Processor:  A word processor is a type of application software that enables to create a documents by enabling to type text, insert page number, header, footer, edit, modify , and to take print or save documents in soft copy for future use.   2. Spreadsheet:   A spreadsheet package is an application software that stores data in an organized way and help to  analyse, calculate, compare the data or values. It also enables to present information in graphs, pie c...