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

ARITHMETIC OPERATIONS ON BINARY NUMBER

Binary arithmetic is simpler to learn because binary number system deals with only two digits - 0 and 1. Binary number perform all arithmetic operation such as Addition, Substraction, Multiplication and compliment as in decimal number system. Binary Addition The addition table for binary arithmetic consist of only the following four entries: 0+0=0 0+1=1 1+0=1 1+1=0 , plus a carry of 1 to the next column.     1011        + 1100    10111     1100    + 1100     11000 Binary Substraction There are three ways to do substraction between binary numbers:- 1. Simple Substraction 2. Substraction using 1's Complement 3. Substraction using 2's Complement Simple Substraction: The complete table of binary substraction is as follows: 0-0=0 0-1=1, borrow 1 from next column 1-0=1 1-1=0    1101 - 0101   1000     1001   - 0111    0...

Media Of Communication Part 2

Unguided Media Unguided media transport electromagnetic wave without using a physical connection. This type of communication referred as wireless communication. We can divided wireless transmission in :-   1. Radio Wave:- Electromagnetic   waves ranging in frequencies between 3KHz and 1GHz are normally called radio wave.   On radio wave connectivity used communication used Bluetooth, Wi-Fi, etc.     Bluetooth :- It is a wireless network connectivity that enables to connect or transfer data between devices over a short range the physical range of connection up to 100 meter. Ex- Mobile phone, barcode scanning, portable speaker, wireless keyboard, mouse etc.      Wi-Fi (Wireless Fidelity):- Wi-Fi is a network of wireless connection. Wi-Fi network establish by radio frequency like Bluetooth, but has more power, resulting a strong connection.    ·   Wi-Fi is also called wireless Ethernet. It has connectivity range up...

BASIC STRUCTURE OF A COMPUTER SYSTEM

Computer Function A computer performs action and accomplishes its task in three basic stages namely:- INPUT – Input is the data that is fed into the computer by the user. PROCESS – Processing refers to the series of action by which the computer converts raw data into information. OUTPUT – Output is the result which is termed as information. Input Unit Data and instructions enter a computer through an input unit in a form that depends upon the input device used. Ex- Keyboard, Mouse, Joystick, Scanner etc. CENTRAL PROCESSING UNIT (C.P.U) CPU is also known as the brain of the “Brain of Computer”. As it appears as a hardware component, but it is also a functional component of a computer system. Functional Elements of a CPU        1.        Arithmetic Logic Unit(ALU)        2.        Control Unit(C.U)        3.    ...