DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1
sqrt(x, /)
Return the square root of x.

If you want to get a square root of a number, you can use
the sqrt() method by calling math.sqrt and passing a
value to it, as shown here:


>>> math.sqrt(15)
3.872983346207417

You have to type a module’s name each time you want to
use one of its capabilities. This isn’t too painful if you’re
using a module with a short name, such as math, but if
you use a module with a longer name, such as the
calendar module, you might wish you could shorten the
module name. Python lets you do this by adding as and a
short version of the module name to the end of the
import command. For example, you can use this
command to shorten the name of the calendar module
to cal.


>>> import calendar as cal

Now you can use cal as an alias for calendar in your
code, as shown in this example:


Click here to view code image


>>> print(cal.month(2020, 2, 2, 1))

February 2020
Mo Tu We Th Fr Sa Su
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29
Free download pdf