02 . Perform Operations using Data Types and Operations 1 Flashcards

1
Q

In python, what is the difference between a single equals sign and a double equal sign?

A

A single equals sign is assigning a value to a variable.

A double equals sign is asking whether something is equal.

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

What will be the output of the following two print statements?

a = 15
b = 25
c = 15

print( a == b)

print( a == c)

A

The print statement will evaluate to Boolean values.

False

True

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

What will be the output of the following two print statements?

a = 15
b = 25
c = 15

print( a <= b)

print( a != c)

A

True

False

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

Name the three logical keywords used in Python

A
  1. and
  2. or
  3. not
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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)

A

True

False

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

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)

A

False

True

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

What will be the output of the print statement?

a = 8
b = 3

print( a ** b)

A

** means exponent, i.e. 8 x 8 x 8

Answer = 512

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

What will be the output of the print statement?

a = 8
b = 3

print( a % b)

A

% means modulus, as in the remainder.

Answer = 2

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

What will be the print statement output?

sales = [30000, 32000, 25000, 4000]

print( 25000 in sales)

A

True

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

What is the difference between x = 5 and x ==5?

A

x = 5 indicates that x is equal to 5

x == 5 is asking if x is equal to 5

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

What is the order of operations?

A

PEMDAS

  1. Parentheses (simplify inside ‘em)
  2. Exponents
  3. Multiplication and Division (from left to right)
  4. Addition and Subtraction (from left to right)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly