Python Basic Numerical Operator Flashcards

 

card 1 of 18

 

2*3+4

 

the * operator has priority over the + operator

10

card 2 of 18

 

2*(3+4)

 

parenthesized expressions are evaluated first

14

card 3 of 18

 

5-3-2-1

 

normal evaluation order is left-to-right

-1

card 4 of 18

 

5-(3-2)-1

 

parenthesized expressions are evaluated first

3

card 5 of 18

 

1/2

 

Python 2 and Python 3 have different answers

0 in Python 2, but 0.5 in Python 3

card 6 of 18

 

1//2

 

Python 2 and Python 3 have different answers

error in Python 2, 0 in Python 3

card 7 of 18

 

7/0

 

ZeroDivisionError

card 8 of 18

 

2**3

 

some languages use the ^ symbol instead of **

8

card 9 of 18

 

2**-3

 

the "-" operator is a minus sign

0.125

card 10 of 18

 

5.0/3

 

computers actually can't represent real numbers

0.16666666666666667

card 11 of 18

 

2.0/2.2E5

 

scientific notation uses "e" or "E" for exponent

9.090909090909091e-06

card 12 of 18

 

1000*2e-3

 

2.0

card 13 of 18

 

(1000*2)e-3

 

exponent in number is not an operator

SyntaxError: invalid Python syntax

card 14 of 18

 

015

 

Python 3 and Python 2 have different interpretations

Syntax error in Python 3, but 13 in Python 2

card 15 of 18

 

035-1

 

Python 3 and Python 2 have different interpretations

Syntax error in Python 3, but 28 in Python 2

card 16 of 18

 

1.1j

 

Python allows complex numbers (square root of -1)

1.10000000000000001j

card 17 of 18

 

1+2j

 

Python allows complex numbers (square root of -1)

(1+2j)

card 18 of 18

 

(1+1j)*(1-1j)

 

Python allows complex numbers (square root of -1)

(2+0j)

 

End of Problem Set

(use browser reload to restart this problem set)