Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

Chapter 5. Advanced Expressions

The math and random Modules, Bit-Level Operations, Division

This chapter covers some more advanced topics. the section called “The math Module” covers two important modules, math and random. the section called “Division Operators” covers the important distinction between the division operators. We also provide some supplemental information that is more specialized. the section called “Bit Manipulation Operators” covers some additional bit-fiddling operators that work on the basic numeric types. the section called “Expression Style Notes” has some notes on style.

Using Modules

A Python module extends the Python execution environment by adding new classes, functions and helpful constants. We tell the Python interpreter to fetch a module with a variation on the import statement. There are several variations on import , which we'll cover in depth in Part IV, “Components, Modules and Packages”.

For now, we'll use the simple import :

import m

This will import module m. Only the module's name, m is made available. Every name inside the module m must be qualified by prepending the module name and a .. So if module m had a function called spam, we'd refer to it as m.spam.

There are dozens of standard Python modules. We'll get to the most important ones in Part IV, “Components, Modules and Packages”. For now, we'll focus on extending the math capabilities of the basic expressions we've looked so far.


 
 
  Published under the terms of the Open Publication License Design by Interspire