Python Operators Flashcards

1
Q

What are Comparison operators?

A

In Python, comparison operators are used to compare two values and return a boolean value, either True or False. Common comparison operators include:

•	== (equal to)
•	!= (not equal to)
•	> (greater than)
•	< (less than)
•	>= (greater than or equal to)
•	<= (less than or equal to)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does == mean?

A

means check for equality

Examples

2 == 2 True

3 == 0 false

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

What does != mean?

A

Examples

2 != 2 False

2 != 1 True

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

Whats is this: %?

A

Modulus the maths out a remainder of something.

Example:

20 % 3 = 3

10 % 3 = 1

11 % 3 = 2

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

Waht is this: //?

A

Floor division

unlike normal division where the left operand is divided by the right, floor division divises that result into whole number, but adjusted to the left in the number line.

Example:
10/3 = 3.33333r

10//3 = 3

9/2 = 4.5

9//2 = 4

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

What is **?

A

Exponent

example:

3 ** 3 = 27

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

Write another way of: x = x + 1

A

x += 1

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