Page 347 - Informatics_Practices_Fliipbook_Class12
P. 347

Viva Voce Questions





               1.  Consider the following dictionary:

                  stateCapitals = {"Punjab":  "Chandigarh", "Uttar Pradesh": "Lucknow", "Tamil
                  Nadu": "Chennai"}
                  Write code to:

                  (i)  Add the state as "Karnataka" and capital as " Bengaluru" in the above dictionary.
                  (ii)  Display a list of all the states in stateCapitals.

             Ans. (i)  Caps['Karnataka'] = 'Bengaluru'
                  (ii)  sorted(Caps.items( ))
               2.  What will be the output produced on execution of the following code?

                  lst = [1, 3, 6, 82, 5, 7, 11, 92]

                  print(lst[2:5])
             Ans. [6, 82, 5]

               3.  What are the key features of Python programming?
             Ans. Python is a versatile and widely-used programming language known for its simplicity and readability. It has
                  many key features that make it popular among developers for a variety of applications. Here are some of the key
                  features of Python programming:
                  (i)  Extensive Standard Library

                  (ii)  Dynamic Typing
                  (iii)  Open Source
                  (iv)  Object-Oriented

               4.  Write a statement in Python to create a dictionary whose keys are 1, 2, 3 and values are Monday, Tuesday and
                  Wednesday respectively.

             Ans. day = {1: 'Monday', 2: 'Tuesday', 3: 'Wednesday'}
               5.  What are the difference between a list and a tuple?

             Ans.                    List                                        Tuples
                   A list is mutable.                        A tuple is immutable.
                   Lists  are  enclosed  in  brackets[]  and  their  Tuples are enclosed in parethesis() and can not
                   elements and size can be changed.         be updated.
                                                             Example:
                   Example:                                  S = ("Orange", "education")
                   L = [10,11,12,13]                         or
                                                             S = ("orange", "education")

               6.  What are the built-in types that Python provides?
             Ans. Python provides built-in types of two types: mutable and immutable. Mutable types:
                  • List
                  • Sets
                  • Dictionaries

                                                                                            Viva Voce Questions  333
   342   343   344   345   346   347   348   349   350   351   352