Python: Operators

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/29

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

30 Terms

1
New cards

+

Addition - Adds values on either side of the operator

2
New cards

-

Subtraction - Subtracts right hand operand from left hand operand

3
New cards

*

Multiplication - Multiplies values on either side of the operator

4
New cards

**

Exponent - Performs exponential (power) calculation on operators

5
New cards

/

Division - Divides left hand operand by right hand operand

6
New cards

//

Floor Division - The division of operands where the result is the quotient in which the digits after the decimal point are removed.

9//2 is equal to 4 and 9.0//2.0 is equal to 4.0

7
New cards

%

Modulus - Divides left hand operand by right hand operand and returns remainder

8
New cards

<

Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.

9
New cards

>

Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.

10
New cards

<=

Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.

11
New cards

>=

Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.

12
New cards

==

Checks if the value of two operands are equal or not, if yes then condition becomes true.

13
New cards

!=

Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.

14
New cards

<>

Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.

(a <> b) is true. This is similar to != operator.

15
New cards

( )

Used to define the parameters of a function, specify arguments passed to a function, or to specify the order of operations in a formula.

16
New cards

[ ]

Used to create a list object.

17
New cards

{ }

Used to create a dictionary object.

18
New cards

@

This is known as decorator syntax. Decorators allow you to inject or modify code in functions or classes.

@decoratorName

def desiredFunction():

pass

19
New cards

,

Commas separate parameters or arguments.

20
New cards

:

Colons denote the beginning of a block of code, or the presence of an index between the objects on its left and right.

21
New cards

.

A dot separates an object's name from the object's attribute being accessed or method being called. Note that some programmers refer to methods as attributes since they belong to an object.

car.door='red'

car.start()

22
New cards

=

Simple assignment operator, Assigns values from right side operands to left side operand

c = a + b will assign value of a + b into c

23
New cards

;

Semicolons can separate different statements on a single line of code.

a = b; d = b + 1; f = "cat"

24
New cards

+=

Add AND assignment operator. It adds right operand to the left operand and assign the result to left operand.

c += a is equivalent to c = c + a

25
New cards

-=

Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operand

c -= a is equivalent to c = c - a

26
New cards

*=

Multiply AND assignment operator, It multiplies right operand with the left operand and assign the result to left operand

c = a is equivalent to c = c a

27
New cards

/=

Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operand

c /= a is equivalent to c = c / a

28
New cards

//=

Floor Dividion and assigns a value, Performs floor division on operators and assign value to the left operand

c //= a is equivalent to c = c // a

29
New cards

%=

Modulus AND assignment operator, It takes modulus using two operands and assign the result to left operand

c %= a is equivalent to c = c % a

30
New cards

**=

Exponent AND assignment operator, Performs exponential (power) calculation on operators and assign value to the left operand

c *= a is equivalent to c = c * a