CH 2 - PYTHON FUNDAMENTALS (Module 2) Flashcards

(29 cards)

1
Q

token/ lexical unit

A
  • in a text, individual words and punctuation marks

- smallest individual unit in a proram

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

5 tokens in python

A
  1. KEYWORDS
  2. IDENTIFIERS (NAMES)
  3. LITERALS
  4. OPERATORS
  5. PUNCTUATORS
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

which is the smallest individual unit in a program

A

TOKEN or LXICAL UNIT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. keywords
A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. identifiers/ names
A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

constraints in naming identifiers

A
  1. first character:
    i. must be letter or underscore (_)
    ii. cant start with number
    iii. cant start with a special character
  2. CANT be a reserved python KEYWORD
  3. python is a case sensitive language. case of letters is significant
  4. CANT have a special character
  5. CAN be a NUMBER
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. literals or values
A

data items that have a fixed value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

types of literals/ values

A
  1. string literals
  2. numeric
  3. boolean
  4. special literal - NONE
  5. literal collections
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

ESCAPE SEQUENCES - \

A

adds backslash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

ESCAPE SEQUENCES - '

ESCAPE SEQUENCES - "

A

adds single quote

adds double quote

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

ESCAPE SEQUENCES - \a
ESCAPE SEQUENCES - \b
ESCAPE SEQUENCES - \f

A
ASCII bell (BEL)
ASCII backspace (BS)
ASCII formfeed (FF)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

ESCAPE SEQUENCES - \n

A

new line character

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

ESCAPE SEQUENCES - \N[name]

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

ESCAPE SEQUENCES - \r

ESCAPE SEQUENCES - \t

A
carriae retrn (CR)
horizontal tab (TAB)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. Operators
A
  • tokens that trigger some computation when applied to variables and other objects in an expression
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

operands

A
  • variables and objects to which the compuattion is applied are called operands
  • thus, an operator requires some operands to work upon
17
Q

types of operators

A
  1. UNARY OPERATORS
  2. 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
18
Q
  1. Arithmetic Operators
A

+ - * /
% remainder/ modulus
** exponent (raise to power)
// floor division

19
Q
  1. Bitwise Operators
A

& bitwise AND
^ bitwise exclusive OR (XOR)
I bitwise OR

20
Q
  1. Shift Operators
A

&laquo_space;shift left

|&raquo_space; shift riht

21
Q
  1. Identity Operators
22
Q
  1. Relational Operators
A
<  > 
<= less than or equal to
>= reater than or equal to
== equal to
!= not equal to
23
Q
  1. Assignment Operators
A
= Assignment
/= Assign quotient
\+= Assign sum
*= Assign product
%= Assign remainder
-= Assign difference
**= Assign exponent
//= Assign floor division
24
Q
  1. Logical Operators
A

and logical AND

or logical OR

25
8. Membership Operators
in | not in
26
' " # \ ( ) [ ] { } @ , : . ` = | are called what in python
punctuators
27
5. 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
28
components of proram
1. Expressions 2. statements 3. comments 4. function 5. block and indentation
29
variables in python are not containers. explain