100% found this document useful (1 vote)
361 views

Python Tokens

Python is a general purpose, high-level programming language that was created in 1991. It can be used to build desktop GUI apps, websites, and web apps. Python has a set of valid characters including letters, digits, special symbols, and whitespace. Keywords are reserved words that have special meaning, while identifiers name variables, functions, and modules - they must start with a letter or underscore and cannot be keywords. Python supports numeric, string, boolean, and special literals as constants, and features common operators like arithmetic, relational, logical, assignment, membership, identity, bitwise, and shift operators. When multiple operators have the same precedence, associativity determines the order of operations from left to right.

Uploaded by

Geetha bharathi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
361 views

Python Tokens

Python is a general purpose, high-level programming language that was created in 1991. It can be used to build desktop GUI apps, websites, and web apps. Python has a set of valid characters including letters, digits, special symbols, and whitespace. Keywords are reserved words that have special meaning, while identifiers name variables, functions, and modules - they must start with a letter or underscore and cannot be keywords. Python supports numeric, string, boolean, and special literals as constants, and features common operators like arithmetic, relational, logical, assignment, membership, identity, bitwise, and shift operators. When multiple operators have the same precedence, associativity determines the order of operations from left to right.

Uploaded by

Geetha bharathi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Python Fundamentals

What is Python?

Python is a general purpose and high level programming


language.

You can use Python for developing desktop GUI applications,


websites and web applications.
It was released in 1991 by Guido van Rossum.
Character Set

Set of valid characters that a language can recognize

1. Letters-A to Z,a to z
2. Digits-0 to 9
3. Special Symbols-+,-,*,%,/,//,{},[],(),# etc
4. White Spaces -blank space,new line etc
Tokens
Keywords/Reserved Words

● Keywords are the words that convey a special meaning to the language
processor.
● They can be used only for special purpose
Identifiers

Identifier is a name used to identify a variable,function,module etc

Rules for naming a variable:

● The first character must be a letter or underscore(_)


● Only Special character allowed is (_)
● No keywords
● No space
Constants/Literals

Numeric String Boolean Special literal

Integer True

Float False None

Complex
Constants/literals

Integer Constant String Constant

1. Decimal (a=6) 1. Single line string

2. Octal (a=0o6) 2. Multi line string

3. Hexadecimal (a=0x6) 3. Escape Sequences

4. Boolean (a=0b1101)
1. Arithmetic
2. Relational
3. Logical
Operator 4. Assignment

Types 5.
6.
Membership
Identity
7. Bitwise
8. Shift
Arithmetic

1. +
2. -
3. *
4. /
5. //
6. %
7. **
Relational

1. <
2. >
3. <=
4. >=
5. ==
6. !=
Logical

1. And
2. Or
3. not
Assignment

1. = Assignment
2. /= Assign Quotient
3. += Assign sum
4. *= Assign product
5. %= Assign remainder
6. -= Assign difference
7. **= Assign exponent
8. //= Assign floor division
Membership

1. In whether variable is available in sequence


2. Not in whether variable is not in sequence
Identity

1. Is is the identity same?


2. Not is is the identity not same?
Bitwise

1. & Bitwise And


2. | Bitwise OR
3. ^ Bitwise XOR
4. ~ Bitwise complement
Shift

1. << shift left


2. >> shift right
Associativity of Python Operators

When two operators have the same precedence, associativity helps to


determine the order of operations.

Associativity is the order in which an expression is evaluated that has


multiple operators of the same precedence. Almost all the operators have
left-to-right associativity.

You might also like