#mastery13 Importing and using Python modules

An example of this can be found on my WSQ06, here’s the part of the code where i imported a module:

import random imported the module random that in this case it produces a random intenger from a certain parameter 

value= random.randint(1,100) this line does is that the variable value will become a random integer (random.randint) from 1 to 100 (1,100)

print(value)

This program will show a random value from 1 to 100.

Another example is:

import math import the module math which has lots of functions that can be found here https://docs.python.org/2/library/math.html

pi=math.pi will take math.pi’s value which  is equivalent to 3.1416…

print (pi)

This program will show:

3.141592653589793

CC BY 4.0 #mastery13 Importing and using Python modules by Gilberto Rogel García is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.