CBSE CS and IP

CBSE Class 11 & 12 Computer Science and Informatics Practices Python Materials, Video Lecture

Using Python Libraries (3 MARKS QUESTIONS)


  1. What is Module, Package, and Library in Python?               
  2. How the following import statements are different, explain with programming examples:        
    •   import X
    •   from X import *
    •   from X import a,b
  3. Consider the following code :
    1
    2
    3
    4
    5
    import math
    import random
    print(str(int(math.pow(random.randint(2,4),2))), end =" ") #Statement1
    print(str(int(math.pow(random.randint(2,4),2))), end =" ") #Statement2
    print(str(int(math.pow(random.randint(2,4),2)))) #Statement3
    
    What could be the possible outputs out of the given choices, also state the reason for each option, why :
    • 2 3 4
    • 9 4 4
    • 16 16 16
    • 2 4 9
    • 4 9 4
    • 4 4 4
  4. Create a module length conversion.py that stores function for various length conversions e.g.
    • miletokm( ) to convert miles to kilometers
    • kmtomile( ) to convert kilometers to miles
    • feettoinches( ) to convert feet to inches
    • inchestofeet( ) to convert inches to feet
    Make sure the above module meets the requirement of being a Python module. Also, you should be able to import the above module using the import command.

No comments:

Post a Comment