Lecture 3 Notes
Lecture 3 Notes
Lecture No. 3
Sr.
Content Description Example
No.
>
Greater than:
x>y
True if left operand is
greater than the right.
False if left operand is
smaller than the right.
<
Less than:
x<y
True if left operand is
Less than the right.
False if left operand is
Relational Greater than the right.
1) Operators
>, >=, <, <= >=
Greater than or equal
to:
x >= y
True if left operand is
greater than or equal to
the right
<=
Less than or equal to:
x <= y
==
Equal to:
x == y
True if both operands
Equality are equal
2) Operators
!=
== , != Not Equal to:
x != y
True if both operands
are not equal
and
x and y
True if both the
operands are true
Logical Operators
3) or
and, or, not x or y
True if either of the
operands is true
not
not x
True if operand is false
False if operand is True
=
Equal to
Assignment
+=
operator Subtract and assign
=
4) Add right operand to
+=
-= left operand and then
assign addition value to
left operand
-=
Subtract and assign
Multiply right
operand with left
operand and then
assign Multiplication
value to left operand
/=
Divide and assign
Assignment
operator //=
*= Divide(floor)and
4) /= assign:
//=
%= Divide left operand
**= with right operand
and then assign the
value(floor) to left
operand
%=
Modulus and assign:
**=
Exponent and assign:
Calculate exponent
value using operands
and assign value to
left operand
String = A sequence of
characters
a)
You cannot use single
quote inside single
quote.
Use \ before inside
single quote for this.
By referencing index
numbers, we can
isolate one of the
characters in a string.
We do this by putting
the index numbers in
square brackets.
We can also call out a range of characters (Group of
characters) from the string.
When slicing strings, we are creating a substring, which is
essentially a string that exists within original string.
With slices, we can
call multiple character
values by creating a
range of index
numbers separated by
8) Slicing
a colon [x:y]
When constructing a
slice, as in [2:4], the
first index number is
where the slice starts
(inclusive), and the
second index number
is where the slice ends
(exclusive)
If nothing is specified
[ :y]= Will start from
0th index up to
y(exclusive)
[x: ]=Will start from
x(inclusive) up to last.
8) Slicing
Slicing using
[x:y:z] format
X= start (inclusive)
y= end (exclusive)
Z= jump to next Zth
character.
Or skip (z-1) numbers
[ x: y: -z]
From Xth character to
Yth character by
skipping (-Z+1)
characters.
9) String Reversing
[ : : -Z]
Start from rightmost
end to leftmost by
skipping
(-z+1)characters