Previous Index Next

Review Questions

Multiple Choice


1. This built-in function can be used to convert an float value to a int.

  1. float_to_int()
  2. float()
  3. convert()
  4. int()

2. Which of the following statements will cause an error?

  1. num = 17
  2. 17 = num
  3. num = 99999
  4. num = '17'

3. A string literal in Python must be enclosed in

  1. parentheses
  2. single-quotes
  3. double-quotes
  4. either single-quotes or double-quotes

4. Which of the following is the valid variable name:

  1. global
  2. 99flag
  3. sum
  4. an$wer

5. Which are correct arithmetical operations?

  1. num = 1*2
  2. 4 = 2+2
  3. 5 + 6 = x
  4. Seven = 3 * 4

6. Which operations result in 6?

  1. 50 // 8
  2. 16 % 5
  3. 2 * * 3
  4. 36 * * 0.5

7. If the value of a = 20 and b = 10, then a += b will assign ________ to a

  1. 40
  2. 30
  3. 20
  4. 10

8. The _____ is the modulus operator.

  1. *
  2. %
  3. **
  4. //

Short Answer

9. If a math expression adds a float to an int, what will the data type of the result be?

10. What would the following display?

num = 20
num = 5
print(num)

11. What will the following statement display?

print('John', 'David', 'Rahul', 'Rita', sep='@')

12. What is the type of the following result:

1 + 2.0 + 3

13. What is a variable? What names may variable have?

14. How are keywords different from variable names?

15. What is Runtime error. Explain with example.

Programming Exercises

For Lab Programming Questions click here.

Previous Index Next