Python: Math and Logic Operators

¡Supera tus tareas y exámenes ahora con Quizwiz!

PEMDAS

1. Parentheses 2. Exponent 3. Multiplication, Modulus, Division 4. Addition, Subtraction

What will be printed? print(12 % 13)

12 *12/13 is 0 with a remainder of 12

What will be printed? print((2 + 4) * 3)

18

What will be printed? n = 1 n = n + 1 print(n)

2

What will be printed? a = 15 b = 10 print(a + b)

25

Float

A real number with decimal precision. Use a float when you need an exact numeric result that is not rounded to the nearest integer. Ex. 2.34

Boolean

A true or false value.

Decrementing

Decreasing a value

Which operator takes the number on the left of it and raises it to the power of the number on the right of it?

Exponent (**)

What will be printed? n = 19 print( n >= 10 and n < 100 and n%2 == 0)

False * Any even number greater than or equal to 10 and less than 100 will print true.

A back slash (\) is used for division.

False A forward slash (/) is used for division.

Incrementing

Increasing a value

and

The and operator produces True if both boolean values on the left and right are True.

Equality

The double equal sign == produces a boolean based on whether the left side is equal to the right side.

Inequality

The inequality operator != produces a boolean based on whether the left side is not equal to the right.

An asterisk (*) is used for multiplication.

True

If the result of a%b is 0, a is divisible by b?

True

The + and - signs are operators.

True

>

greater than

>=

greater than or equal to

<

less than

<=

less than or equal to

What will be printed? print(5 != 3)

true

What will be printed? x = 3 print(x >= 2 and x <= 5)

true


Conjuntos de estudio relacionados

Introduction to Tax Law (Quiz 1)

View Set

OB Chapter 14-Nursing Management During Labor and Birth

View Set

APICS Module 1 - Material Requirements Planning (D) - Terms

View Set

SOCIAL PSYCHOLOGY - Zimbardo Study

View Set

SHRM - Developing a Global Mindset

View Set

EXPLORE: Discover Topographic Maps

View Set

M4 practice assignment (connect quiz practice)

View Set