Python Assessment

Python Assessment

  1. What is the maximum length of a Python identifier?

    a) 32 b) 128 c) No fixed length is specified
  2. What will be the output of the following code snippet?

                            var = 10
                            print(type(var))
                            var = "hello"
                            print(type(var))
                        
    a) str and int b) int and str c) int and int
  3. Which of the following types of loop are not supported in Python?

    a) for b) while c) do-while
  4. Which of the following blocks will always be executed whether an exception is encountered or not in a program?

    a) try b) except c) finally
  5. What is the keyword used in Python to raise an exception?

    a) raise b) try c) goto
  6. Which of the following modules needs to be imported to handle date-time computations in Python?

    a) datetime b) date c) time
  7. In which language is Python written?

    a) C++ b) Java c) C
  8. What will be the output of the following code?

                            a = [1, 2, 3]
                            b = a
                            b[0] = 5
                            print(a)
                        
    a) [1, 2, 3] b) [5, 2, 3] c) [1, 2, 3, 5]