redd 發表於 2016-9-21 16:51:13

built-in functions

maximum = max(5, 8, 9)
print maximumminimum = min(1, 4, 2)
print minimum

redd 發表於 2016-9-21 16:52:34

absolute = abs(-42)
print absolute

redd 發表於 2016-9-21 16:54:06

print type(42)
print type(4.2)
print type('spam')

redd 發表於 2016-9-21 17:33:25

def distance_from_zero(ds):
    if type(ds) == int or type(ds) == float:
      return abs(ds)
    else:
      return 'Nope'
頁: [1]
查看完整版本: built-in functions