02 . Perform Operations using Data Types and Operations 1 Flashcards
In python, what is the difference between a single equals sign and a double equal sign?
A single equals sign is assigning a value to a variable.
A double equals sign is asking whether something is equal.
What will be the output of the following two print statements?
a = 15 b = 25 c = 15
print( a == b)
print( a == c)
The print statement will evaluate to Boolean values.
False
True
What will be the output of the following two print statements?
a = 15 b = 25 c = 15
print( a <= b)
print( a != c)
True
False
Name the three logical keywords used in Python
- and
- or
- not
What will be the output of the following two print statements?
a = 15
b = 25
c = 15
d = 20
print( a == c and b !=c)
print( a == b and b == c)
True
False
What will be the output of the following two print statements?
a = 15
b = 25
c = 15
d = 20
print( a == b or b == c)
print( not a == b or b == c)
False
True
What will be the output of the print statement?
a = 8 b = 3
print( a ** b)
** means exponent, i.e. 8 x 8 x 8
Answer = 512
What will be the output of the print statement?
a = 8 b = 3
print( a % b)
% means modulus, as in the remainder.
Answer = 2
What will be the print statement output?
sales = [30000, 32000, 25000, 4000]
print( 25000 in sales)
True
What is the difference between x = 5 and x ==5?
x = 5 indicates that x is equal to 5
x == 5 is asking if x is equal to 5
What is the order of operations?
PEMDAS
- Parentheses (simplify inside ‘em)
- Exponents
- Multiplication and Division (from left to right)
- Addition and Subtraction (from left to right)