-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnumeric.py
More file actions
30 lines (26 loc) · 1.12 KB
/
Copy pathnumeric.py
File metadata and controls
30 lines (26 loc) · 1.12 KB
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
def numeric(x, y, f, l):
print "int: -1024 =", x
print "float: 3.14 =", f
print "long: 1L =", l
print "x + y =", x + y # sum of x and y
print "x - y =", x - y # difference of x and y
print "x * y =", x * y # product of x and y
print "x / y =", x / y # quotient of x and y
print "x // y =", x // y # (floored) quotient of x and y
print "x % y =", x % y # remainder of x / y
print "-x =", -x # x negated
print "+x =", +x # x unchanged
print "abs(x) =", abs(x) # absolute value or magnitude of x
print "int(x) =", int(f) # x converted to integer
print "float(x) =", float(y) # x converted to floating point
# print "divmod(x, y) =", divmod(x, y) # the pair (x // y, x % y)
# print "pow(x, y) =", pow(x, y) # x to the power y
def entry_point(argv):
x = -1024 # plain integer
y = 42
f = 3.14 # float
l = 1L # a long integer
numeric(x, y, f, l)
return 0
def target(*args): return entry_point
if __name__ == "__main__": import sys; entry_point(sys.argv)