0% found this document useful (0 votes)
16 views6 pages

First Note

The document discusses different types of tokens in programming languages including keywords, identifiers, literals/values, operators, and punctuators. Keywords are reserved words with special meaning, identifiers name variables and objects, literals are values like numbers and strings, operators perform computations, and punctuators help organize code.

Uploaded by

shekhar bhandari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

First Note

The document discusses different types of tokens in programming languages including keywords, identifiers, literals/values, operators, and punctuators. Keywords are reserved words with special meaning, identifiers name variables and objects, literals are values like numbers and strings, operators perform computations, and punctuators help organize code.

Uploaded by

shekhar bhandari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

#just to save my nose I think you already have these but I will explain

like I am talking

There is thing called “tokens “according to book,” (it is smallest


individual unit in a program), they are classified into different shits like
1. (Keywords) A.T.B keywords is word having special meaning
reserved by programming language. this is just like the print
#*print is not keywords nor the tokens it is function()*command
we used before it is the language of computer and the humans
there is some special words with specific purpose like
[True, False, else, if, elif, while, for, in, or, and, not, from, del…….] #I
remember this much google for more 
They should not be used as Identifiers (the thing we used before = like
p,t,r we can’t use else=1)
2. (Identifiers) As the word define itself it is used to define shits like
Variables, objects, classes, function, lists , dictionaries. There are
some rules to set the identifiers.
a. We can’t use identifiers
b. First letter must me letters and “_ “is counted as letters.
c. Big letters and small letters are treated as different in short it is
“case sensitive”.

3. (literals/values)

The thing we used after = are literals or the values as we used two
different things like “1+1” and 1+1 actually there are 4 main different
types of literals.
A. String literals the thing we used with quotation “” you might
be wondering if single quote works or not, but it works I don’t
know the difference between them but both works as same.
Don’t be confused with the symbols these symbols are
classified as Punctuators.
String literals are something enclosed with single or double
quotation. There is some deep shit inside it like what if you
want to add (“) inside the string. there is a thing called escape
sequence .I don’t know if I am overthinking or going too deep
we’ll discuss in class this is slightly deep .

B. Numerical literals as name define itself numbers like 123, 1+1,


and 1-1 there are 3 different types of Numerical INTERERS,
FLOAT, complex we need to practically understand this.

C. Boolean literals this is where you start becoming a coder this


is so simple there are two things you need to know True and
False.

D. Special literals there is only one special literals in python


“none “ #*I think you got the idea that python is basic
programming language*

4. (operators)

These are some special symbols that does calculation or “computation”


this is kind of sensitive shit you need to know all the operators.
Arithmetic Operators
Arithmetic operators are used to perform mathematical operations like addition,
subtraction, multiplication, and division.
Operator Description Syntax

+ Addition: adds two operands x+y

– Subtraction: subtracts two operands x–y

* Multiplication: multiplies two operands x*y

/ Division (float): divides the first operand by the second x/y

// Division (floor): divides the first operand by the second x // y

Modulus: returns the remainder when first operand is divided by


% the second x%y

** Power : Returns first raised to power second x ** y

Comparison Operators
Comparison or Relational operators compare the values. It either returns
True or False according to the condition.

Operator Description Syntax

> Greater than: True if left operand is greater than the right x>y

< Less than: True if left operand is less than the right x<y

== Equal to: True if both operands are equal x == y

!= Not equal to – True if operands are not equal x != y


Operator Description Syntax

Greater than or equal to: True if left operand is greater than or


>= equal to the right x >= y

Less than or equal to: True if left operand is less than or equal to
<= the right x <= y

Logical Operators
Logical operators perform Logical AND, Logical OR, and Logical NOT operations. It
is used to combine conditional statements.

Operator Description Syntax

and Logical AND: True if both the operands are true x and y

Logical OR: True if either of the operands is


or true  x or y

not Logical NOT: True if operand is false  not x

Bitwise Operators

Bitwise operators act on bits and perform the bit-by-bit operations. These are
used to operate on binary numbers.
Operator Description Syntax

& Bitwise AND x&y

| Bitwise OR x|y

~ Bitwise NOT ~x

^ Bitwise XOR x^y


Operator Description Syntax

>> Bitwise right shift x>>

<< Bitwise left shift x<<

Assignment Operators 
Assignment operators are used to assign values to the variables.
Operator Description Syntax

Assign value of right side of expression to left side


= operand  x=y+z

Add AND: Add right side operand with left side


+= operand and then assign to left operand a+=b     a=a+b

Subtract AND: Subtract right operand from left


-= operand and then assign to left operand a-=b     a=a-b

Multiply AND: Multiply right operand with left


*= operand and then assign to left operand a*=b     a=a*b

Divide AND: Divide left operand with right operand


/= and then assign to left operand a/=b     a=a/b

Modulus AND: Takes modulus using left and right


%= operands and assign result to left operand a%=b     a=a%b

Divide(floor) AND: Divide left operand with right


//= operand and then assign the value(floor) to left operand a//=b     a=a//b

Exponent AND: Calculate exponent(raise power) value


**= using operands and assign value to left operand a**=b     a=a**b

Performs Bitwise AND on operands and assign value


&= to left operand a&=b     a=a&b
Operator Description Syntax

Performs Bitwise OR on operands and assign value to


|= left operand a|=b     a=a|b

Performs Bitwise xOR on operands and assign value to


^= left operand a^=b     a=a^b

Performs Bitwise right shift on operands and assign


>>= value to left operand a>>=b     a=a>>b

Performs Bitwise left shift on operands and assign a <<= b     a= a <<


<<= value to left operand b

5. (Punctuators)

These are just the bunch of symbols left behind and it helps to organize
shits.
Most common punctuation are
‘ “ # \ !(not /) ( ) { } [ ] @ , : . ` =

You might also like