Python

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Solitaire SIMPLE

CREATIVE

Infosys INNOVATIVE

Name – SHALOM GOSAIN


python
• * PYTHON IS A GENERAL PURPOSE ,
DYNAMICALLY TYPED , HIGH LEVEL
LANGUAGE.

• * PYTHON IS DEVELOPED BY “GUIDO VAN


ROSSUM” IN THE YEAR 1991.

• * PYTHON CODE DOESN’T NEED TO BE


COMPILED BEFORE BEING RUN.
• * OPERATORS IS NOTHING BUT SYMBOLS THAT
PERFORMS SOME TASKS .

• * OPERATORS ARE USED TO PERFORM OPERATIONS


ON VARIABLES AND VALUES.

• * THE VALUES THAT AN OPERATORS ACTS ON ARE


OPERATORS IN CALLED OPERANDS .
PYTHON
• * IN PYTHON , OPERATORS ARE SPECIAL SYMBOLS
THAT DESIGNATE THAT SOME SORT OF
COMPUTATION SHOULD BE PERFORMED.

• * THESE OPERATORS ARE USED FOR THE PURPOSE


OF LOGICAL , ARITHMETIC AND VARIOUS OTHER
OPERATIONS.
Types of operators in python

Arithmetic Relational Membership Logical


operators operators Operators
Assignment
Operators Operators
ARITHMETIC OPERATORS
* Arithmetic operators are used with numeric values to perform common mathematical operations:

Operations of Arithmetic operators


• * ADDITION
• *SUBTRACTION
• *MULTIPLICATIONS
• * DIVISION
• * MODULUS
• *EXPONENTIATION
• *FLOOR DIVISION
Operators of Arithmetic operations
* Python Arithmetic Operators are used to perform mathematical operations like addition, subtraction,
multiplication, and division.

Operator Name Example

+ Addition x+y

- Subtraction x-y

* Multiplication x*y

/ Division x/y

% Modulus x%y

** Exponentiation x ** y

// Floor division x // y
Example of arithmetic operators

a = 7 b = 2 # addition print ('Sum: ', a + b)


# subtraction print ('Subtraction: ', a - b)
# multiplication print ('Multiplication: ', a * b)
# division print ('Division: ', a / b)
# floor division print ('Floor Division: ', a // b) #
modulo print ('Modulo: ', a % b)
# a to the power b print ('Power: ', a ** b)
Operators of assignment operators
* Here, we will cover Assignment Operators in Python. So, Assignment Operators are used to assigning values to
variables. 
Operator Example Same As

= x=5 x=5

+= x += 3 x=x+3

-= x -= 3 x=x-3

*= x *= 3 x=x*3

/= x /= 3 x=x/3

%= x %= 3 x=x%3

//= x //= 3 x = x // 3

**= x **= 3 x = x ** 3

&= x &= 3 x=x&3

|= x |= 3 x=x|3

^= x ^= 3 x=x^3

>>= x >>= 3 x = x >> 3

<<= x <<= 3 x = x << 3


Example of assignment operators

# assign 10 to a
a = 10

# assign 5 to b
b=5

# assign the sum of a and b to a


a += b #a=a+b

print(a)

# Output: 15
Operators of logical operators
* In Python, logical operators carry out logical operations and return Boolean values based on the result. We need to
verify multiple conditions simultaneously or use logical operators by combining multiple conditions in some cases.
There are three types of logical operators in Python:

Operator Example Meaning

Logical AND:
and a and b
True only if both the operands are True

Logical OR:
or a or b
True if at least one of the operands is True

Logical NOT:
not not a True if the operand is False and vice-
versa.
EXAMPLE OF
LOGICAL
OPERATORS

•a = 5
•b = 6

•print((a > 2) and (b >= 6)) #


True
Membership operators
* Python’s membership operators test for membership in a sequence, such as strings, lists, or tuples. There are
two membership operators as explained below −

Operator Description

in  Returns True if a sequence with the specified value is


present in the object

not in Returns True if a sequence with the specified value is not


present in the object
RELATIONAL
OPERATORS Operator Name Example Try it

== Equal x == y
•* Relational operators are != Not equal x != y
used for comparing the
values. It either returns True > Greater than x>y
or False according to the
condition. These operators < Less than x<y
are also known
>= Greater than or equal to x >= y
as Comparison Operators.
<= Less than or equal to x <= y
Example of relational
operators
a=5

b=2
a =5
b =2 # equal to operator
print('a == b =', a == b)
print (a > b) # True
# not equal to operator
print('a != b =', a != b)

# greater than operator


print('a > b =', a > b)

# less than operator


print('a < b =', a < b)
LOOP
LOOP IS A SIMPLE REGISTER LANGUAGE
THAT PRECISELY CAPTURES THE PRIMITIVE
RECURSIVE FUNCTIONS
Thankyou

You might also like