CH 2 - PYTHON FUNDAMENTALS (Module 2) Flashcards
token/ lexical unit
- in a text, individual words and punctuation marks
- smallest individual unit in a proram
5 tokens in python
- KEYWORDS
- IDENTIFIERS (NAMES)
- LITERALS
- OPERATORS
- PUNCTUATORS
which is the smallest individual unit in a program
TOKEN or LXICAL UNIT
- keywords
- words that convey a special meaning to the language compiler/ interpreter
- reserved for special purpose
- cant be used as identifier names
- print, true, false, for, in, while, elif, none
- identifiers/ names
- fundamental building blocks of a program
- arbitrary long sequence of letters and digits
- used as the general terminology for the names given to different parts of the program viz. variables, objects etc
constraints in naming identifiers
- first character:
i. must be letter or underscore (_)
ii. cant start with number
iii. cant start with a special character - CANT be a reserved python KEYWORD
- python is a case sensitive language. case of letters is significant
- CANT have a special character
- CAN be a NUMBER
- literals or values
data items that have a fixed value
types of literals/ values
- string literals
- numeric
- boolean
- special literal - NONE
- literal collections
ESCAPE SEQUENCES - \
adds backslash
ESCAPE SEQUENCES - '
ESCAPE SEQUENCES - "
adds single quote
adds double quote
ESCAPE SEQUENCES - \a
ESCAPE SEQUENCES - \b
ESCAPE SEQUENCES - \f
ASCII bell (BEL) ASCII backspace (BS) ASCII formfeed (FF)
ESCAPE SEQUENCES - \n
new line character
ESCAPE SEQUENCES - \N[name]
ESCAPE SEQUENCES - \r
ESCAPE SEQUENCES - \t
carriae retrn (CR) horizontal tab (TAB)
- Operators
- tokens that trigger some computation when applied to variables and other objects in an expression
operands
- variables and objects to which the compuattion is applied are called operands
- thus, an operator requires some operands to work upon
types of operators
- UNARY OPERATORS
- BINARY OPERATORS
i. Arithmetic Operators
ii. Bitwise Operators
iii. Shift Operators
iv. Identity Operators
v. Relational Operators
vi. Assignment Operators
vii. Logical Operators
viii. Membership Operators
- Arithmetic Operators
+ - * /
% remainder/ modulus
** exponent (raise to power)
// floor division
- Bitwise Operators
& bitwise AND
^ bitwise exclusive OR (XOR)
I bitwise OR
- Shift Operators
«_space;shift left
|»_space; shift riht
- Identity Operators
is
is not
- Relational Operators
< > <= less than or equal to >= reater than or equal to == equal to != not equal to
- Assignment Operators
= Assignment /= Assign quotient \+= Assign sum *= Assign product %= Assign remainder -= Assign difference **= Assign exponent //= Assign floor division
- Logical Operators
and logical AND
or logical OR
- Membership Operators
in
not in
’ “ # \ ( ) [ ] { } @ , : . ` =
are called what in python
punctuators
- punctuators
symbols that are used in prorammin languages to organize sentence structures, and indicate the rhythm and emphasis of expressions, statements and program and structure
components of proram
- Expressions
- statements
- comments
- function
- block and indentation
variables in python are not containers. explain