forked from AliceWonderland/hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfab.py
38 lines (29 loc) · 921 Bytes
/
fab.py
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
30
31
32
33
34
35
36
37
38
# Python code to demonstrate working
# of fabs() and abs()
import math
#################################
# When the argument is an integer#
#################################
number = -10
# abs() will return an integer as
# the argument is an integer
print(abs(number))
# fabs() will return a floating point number
print(math.fabs(number))
###########################################
# When the input is a floating point number#
###########################################
number = -12.08
# abs() will return an floating point number
# as the argument is a floating point number
print(abs(number))
# fabs() will return a floating point number
print(math.fabs(number))
####################################
# When the input is a complex number#
####################################
number = complex(3, 4)
# abs() will return the magnitude
print(abs(number))
# fabs() will return an error
# print(math.fabs(number))