A Deep Dive into Arithmetic, Comparison, Logical operators & More

## What you’ll learn

- What is the primary function of arithmetic operators?
- What are the different types of arithmetic operators in Python?
- What are the various types of assignment operators?
- What is the purpose of a comparison operator?
- What are logical operators used for?
- What are the three most common logical operators?
- What are the two types of membership operators?
- What is the difference between a tuple and a list?
- Explain the difference between the identity operator (is) and the equality operator (==) in Python.
- On what level do bitwise operators work?

## Requirements

- Basic Knowledge of computer

## Description

1. What is the primary function of arithmetic operators?

A) To check if a value exists within a sequence.

B) To perform calculations on numerical values.

C) To define new functions within a program.

D) To concatenate strings together.

2. Which of the following is NOT an arithmetic operator?

A) + (addition)

B) * (multiplication)

C) == (equal to)

D) / (division)

3. Evaluate the following expression: 5 + 3 * 2. What is the answer (considering standard order of operations)?

A) 11

B)16

C) 20

D) 25

4. What are the different types of arithmetic operators in Python?

5. What do you know about precedence chart for arithmetic operators?

6. What is Floor Division? Whether it rounds the result down or upward to the nearest integer?

7. What does the modulo operator return after a division operation?

8. What is the primary purpose of an assignment operator?

A) To perform calculations on existing variables.

B) To define a new variable and assign it a value.

C) To compare two values and return a True or False result.

D) To control the flow of a program using conditional statements.

9. Which of the following is the basic assignment operator in most programming languages?

A) + (plus)

B) = (equal)

C) * (asterisk)

D) / (forward slash)

10. What is the difference between a simple assignment (=) and an augmented assignment operator (like += or -=)?

A) There is no difference, both assign values to variables.

B) Augmented assignment operators perform a calculation and then assign the result.

C) Simple assignment only works with numbers, while augmented assignment works with all data types.

D) Simple assignment creates a new variable, while augmented assignment modifies an existing one.

11. What are the various types of assignment operators besides the basic assignment operator (=)?

12. What is the purpose of a comparison operator?

A) To perform arithmetic calculations on numbers.

B) To define new functions within a program.

C) To evaluate the relationship between two values and return a True or False result.

D) To control the flow of a program using loops.

13. Which of the following is a comparison operator in most programming languages?

A) Addition (+)

B) Multiplication (*)

C) Equal to (==)

D) Modulus (%)

14. Consider the statement: x = 10 and y = 5. Would the following expression be True or False? x > y

A) Always True

B) Always False

C) Depends on the specific values of x and y (in this case, True)

D) Cannot be determined without more information.

15. What are comparison operators?

16. What are the common comparison operators in Python?

17. What are logical operators used for?

A) To perform arithmetic operations on numbers.

B) To combine conditions and create complex expressions that evaluate to True or False.

C) To define new variables within a program.

D) To loop through elements in a sequence.

18. What are the three most common logical operators? (Choose all that apply)

A)AND

B) WHILE

C) OR

D) NOT

19. Consider the statement: x = 5 AND y = 10. If x is 3 and y is 10, what will the statement evaluate to?

A) True

B) False

20. Consider the statement: age >= 18 and has_id == True. What will this expression evaluate to (assuming age is 20 and has_id is True)?

A) Always True

B) Always False

C) True only if age is 20 and has_id is True

D) Depends on the value of age

21. What is the difference between the and and or operators?

A) There is no difference, they both work the same way.

B) and requires both conditions to be True, while or requires only one to be True.

22. What do you know about the truth table of ‘and’ logical opertor?

23. In case of ‘or’ logical operator, if the first expression is True, whether there is need to evaluate the second expression?

24. What is the function of ‘not’ logical operator?

25. What is the purpose of a membership operator?

A) Perform mathematical calculations on sequences.

B) Check if a value exists within a sequence (like a list, string, or set).

C) Concatenate strings together.

D) Define new functions within a program.

26. What is the difference between a tuple and a list?

27. What are the two types of membership operators?

28. Which of the following is a membership operator in Python?

A) + (plus)

B) * (asterisk)

C) in

D) == (equal to)

29. Explain the difference between the in operator and the not in operator in Python.

30. What data structures can you use the in operator with? (Choose all that apply)

A) Lists

B) Strings

C)Tuples

D)Dictionaries (works differently with in for keys)

31. The expression ‘apple’ in ‘pineapple’ will evaluate to:

A) True

B) False

32. Given the list fruits = [‘apple’, ‘banana’, ‘orange’], which expression will check if ‘mango’ is present?

A) fruits == ‘mango’

B) ‘mango’ in fruits

33. What is the purpose of an identity operator?

A) To perform calculations on existing variables.

B) To check if two variables refer to the same object in memory, regardless of their values.

C) To compare the values of two variables and see if they are equal.

D) To control the flow of a program using loops.

34. Which of the following is an identity operator in Python?

A) Addition (+)

B) Equal to (==)

C) is

D) in (membership)

35. Consider the following code: x = [1, 2, 3], y = [1, 2, 3], and z = x. Would the following expression be True or False? x is y

A) Always True

B) Always False

C) Depends on the specific values in the lists (in this case, False)

D) True, since both lists have the same elements.

36. Explain the difference between the identity operator (is) and the equality operator (==) in Python.

37. What do bitwise operators operate on?

A) Floating-point numbers

B) Individual bits within a binary number

C) Text strings

D) Logical expressions (True/False)

38. Which of the following is a common bitwise operator?

A) Addition (+)

B) Multiplication (*)

C) AND (&)

D) Greater than (>)

39. Imagine two binary numbers: x = 0101 (decimal 5) and y = 1010 (decimal 10). What is the result of performing a bitwise AND (x & y) operation?

A) 0000 (decimal 0)

B) 0100 (decimal 4)

C) 1111 (decimal 15)

D) Cannot be determined without knowing variable sizes.

40. What is the purpose of the left shift operator (<<) in bitwise operations?

A) It shifts the bits of the operand to the right, discarding bits that fall off the end.

B) It performs a bitwise AND operation with the specified number of bits shifted to the left.

C) It multiplies the operand by the power of 2 equal to the number of bits shifted.

D) It shifts the bits of the operand to the left, filling empty positions with zeros.

## Who this course is for:

- Students who are interested to learn Python