0% found this document useful (0 votes)
2 views

Chapter-8[Introduction to Python Modules]

The document provides an overview of Python modules, defining them as files containing code that can be reused in other programs. It highlights the benefits of modularity, such as code reusability and ease of maintenance, and describes various functions in the math and statistics modules. Additionally, it explains how to import modules and details specific functions like sqrt(), ceil(), and mean().

Uploaded by

asesino02072008
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter-8[Introduction to Python Modules]

The document provides an overview of Python modules, defining them as files containing code that can be reused in other programs. It highlights the benefits of modularity, such as code reusability and ease of maintenance, and describes various functions in the math and statistics modules. Additionally, it explains how to import modules and details specific functions like sqrt(), ceil(), and mean().

Uploaded by

asesino02072008
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Unit-I[Computer System Organization]

Chapter-8[Introduction to Python Modules]

1. Define modules in Python.


Ans. Modules are files containing Python code
(variables, functions, classes) that can be imported
and used in other programs.

2. Define library in Python.


Ans. A library is a collection of modules that
provide a set of functionalities for specific tasks.

3. Define modularity.
Ans. Modularity refers to dividing a program into
separate modules that can be developed, tested,
and maintained independently.

4. What are the benefits of modules in


Python?
Ans. Modules promote code reusability,
organization, readability, and ease of maintenance.

5. What are the two ways to import


modules in Python?
Ans. Using import module_name and from
module_name import function_name.

6. Describe the math module.


Ans. The math module provides mathematical
functions like sqrt(), sin(), cos(), and constants like
pi and e.

7. Describe ceil() function.


Ans. ceil(x) returns the smallest integer greater
than or equal to x.

8. Describe sqrt() function.


Ans. sqrt(x) returns the square root of x.

9. Describe exp() function.


Ans. exp(x) returns e raised to the power of x.

10. Describe fabs() function.


Ans. fabs(x) returns the absolute value of x.

11. Describe floor() function.


Ans. floor(x) returns the largest integer less than
or equal to x.

12. Describe log() function.


Ans. log(x) returns the natural logarithm of x.

13. Describe log10() function.


Ans. log10(x) returns the base-10 logarithm of x.

14. Describe pow() function.


Ans. pow(x, y) returns x raised to the power of y.

15. Describe sin() function.


Ans. sin(x) returns the sine of x radians.

16. Describe cos() function.


Ans. cos(x) returns the cosine of x radians.

17. Describe tan() function.


Ans. tan(x) returns the tangent of x radians.

18. Describe degree() function.


Ans. degrees(x) converts radians to degrees.

19. Describe radian() function.


Ans. radians(x) converts degrees to radians.

20. What is math.pi?


Ans. math.pi is the mathematical constant π
(approx. 3.14159).

21. What is math.e?


Ans. math.e is the mathematical constant e
(approx. 2.71828).

22. Describe random module.


Ans. The random module provides functions for
generating random numbers and performing
random operations.

23. Describe three ways of randrange()


function.
Ans. randrange(stop), randrange(start, stop),
randrange(start, stop, step) generate random
numbers within specified ranges.
24. Describe statistic module.
Ans. The statistics module provides functions for
statistical calculations like mean, median, and
standard deviation.

25. Describe three function of


statistic module.
Ans. mean(data): calculates average,
median(data): finds median value, stdev(data):
computes standard deviation.

You might also like