Library

--Originally published at Hackerman's house

A library is a built-in module that can be used to solve several problems. Once python is installed it includes a series of standard libraries such as math that can be used to solve mathematical problemas or generally just to work better with numbers. There is also the time library to count the time. You can find more information about it here.

https://docs.python.org/3/library/

In this example we’ll be importing the “math” librarie to calcule the area of a circle, the radius will be given by the user and the program will substitute this number in a formula

Import a librarie is simple, the syntax is this:

import name_of_the_library

And the functions included in every library are different, these functions can be find in the link above.

The functions of math that we’ll be using is the pi value.

libraries

The “try” and “except” are used to determine if the input given by the user is a number. The radius is given by the user and the area has a simple formula PI times radius square. That is why we needed the math module.

Here is how the program works.

libraries2

Thanks for reading me.

giphy-5


Modules and Libraries/Calling Functions

--Originally published at Python & pugs

library.gif

Python 3 have so many libraries that you can use when you need them, and you just need to call for them in your program, and in this post I’ll give an example with “math” because is the easiest one (lol).

To make use of the math library you just need to “call” for it:
libraries
So the only to do here is to import the library you want to use, the print whatever you want of the library.
In here you can find all the libraries Python 3 can offer you:
https://docs.python.org/3/library/

but-wait

<THE CREATION OF YOUR OWN PEYOTE (Library)>

To create your own library, you need to make another file where you are going to create a function.

librariesfunction

Now that you have this function, you’ll import it to another file where it is going to run with the number you assign to x.

librariesfunction

And now you made two mastery topics in one!

snoop-dogg-gggggga721eb54a9-290x595x58.gif