Using Python Libraries || Preeti Arora || Class 12 || Unsolved Question || Computer science || Solution



Q1. What is Python library? Explain with example.



Q2. Write a program to calculate the following using modules:

(a) Energy = m * g * h
(b) distance = ut + + 1/2at2
(c) Speed = distance / time




Q3. Write a module to input total number of days and find the total number of months and remaining days after months, and display it in another program.




Q4. Write a program to calculate the volume and area of a sphere inside separate modules and import them in one complete package.

Volume = 4/3Ï€r3
Surface Area = 4Ï€r2





Q5. What is a module? What is the file extension of a Python module?



Q6. How do you reuse the functions defined in a module in your program?



Q7. In how many ways can you import objects from a module?



Q8.  How are following import statements different?

(a) import math
(b) from math import *




Q9. What is the utility of math module?



Q10. How does Python resolve the scope of a name or identifier?



Q11. Find the output of the following:

import math
print (math.floor (5.5))




Q12. Rewrite the following Python code after removing all syntax error(s). Underline the corrections done.

def main():
    r = input ('enter any radius:')
    A - pi * maths.pow (r, 2)
    Print ("Area = "+ a)
        Main()




Q13. What is the significance of assigning namespace to Python modules?



Q14. How are packages and modules related to each other?



Q15. What is the difference between import statement and from import statement?



Q16. Why is from import * statement not recommended for importing Python modules in an external program?




Q17. What is a library?



Q18. What is the importance of site-package folder of Python installation?




Q19. How are following import statements different?

(a) import X
(b) from X import *
(c) from X import a, b, c




Q20. Name the Python Library modules which need to be imported to invoke the following functions:

(I)log()
(ii) pow()




Q21. What is dot notation of referring to objects inside a module?




Q22. Why should the from <module> import <object> statement be avoided to import objects?




Q23. What do you understand by standard library of Python?




Q24. Explain the difference between import <module> and from <module> import statements, with examples.




Q25. Create a module lengthconversion.py that stores functions for various lengths conversion
miletokm  ()  to convert miles to kilometers
kmtomile()   to convert kilometers to miles
feettoinches( )
inchestofeet()
It should also store constant values such as value of (mile in kilometers and vice versa).
[I mile = 1.609344 kilometer; 1 feet = 12 inches]
Help( ) function should display proper information.




Q26. Create a module MassConversior.py that stores function for mass conversion e.g ,
kgtotonne( ) to convert kg to tonnes
tonnetokg() to convert tonne to kg
kgtopound( ) to convert kg to pound
poundtokg()to convert pound to kg
(Also store constants 1 kg - 0.001 tonne, 1 kg = 2.20462 pound)
Help( ) function should give proper information about the module.




Q27. Write a user-defined function to calculate the area of a triangle.




Q28. Write a user-defined function to convert a string with more than one word into title case string where string is passed as parameter. (Title case means that the first letter of each word is capitalized.)




Q29. Write a function deleteChar() which takes two parameters-one is a string and the other is a character. The function should create a new string after deleting all occurrences of the character from the string and return the new string.




Q30. Write a program to print the number of occurrences of a substring into a line using built-in string function find().

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post