Python Interview Questions
• Python - Arithmetic Operators
 1. Increment val_1 by 2? A) val_1 + + 2 B) val_1 += 2 C) val_1 + + 2 Answer: val_1 += 2 2. What is the result of the following expression: 2 + 10 * 5 + 3 * 2 ? A) 126 B) 58 C) 110 D) 112 Answer: 58 3. What is the result of the following expression: 6 * 8 / 2**3 - 2 * 2? A) 8 B) 27644 C) 2 D) 13820 Answer: 2 4. What is the result of running the following code 1/2 * 2 # + 1: A) 2.0 B) 1 C) 1.0 D) Nothing happens at all Answer: 1 Explanation: The comment prevents the latter half of the line from running, so we only get 1/2 * 2 which is 1.0 5. Which of the following result in integers in Python? A) 6/2 B) 5 // 2 C) 6.5 * 2 Answer: 5 // 2 Explanation: Even though the numbers do not cleanly divide, the double slash // is division that results in an integer in Python. 6. What is the result of 111 % 7 A) 15.8571428571428 B) 105 C) 6 Answer: 6 Explanation: 6 is the remainder. We can do 111 / 7, which is floored at 15. So then 15 * 7 = 105; to get to 111 we need 6 more. 7. What type does the following expression result in 1.0 + 4 ? A) Integer B) Float Answer: Float Explanation: Whenever doing math with both floats and ints, the result is a float. Otherwise, we would potentially lose any of our data after the decimal point,. 8. How can we add parenthesis to the following expression to make it equal 100: 1 + 9 * 10 ? A) (1 + 9) * 10 B) It already equals 100 C) (1 + 9 * 10) D) 1 + (9 * 10) Answer: (1 + 9) * 10 9. What is the result of 16 // 6 A) 2 B) 2.666666666665 C) 3 Answer: 2 