func



myd@ubuntu:~$ python3
Python 3.2 (r32:88445, Mar 25 2011, 19:28:28)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def func():
...     global x
...     print('x is', x)
...     x = 2
...     print('change local x to', x)
...
>>> x = 50
>>> func()
x is 50
change local x to 2
>>> print('value of x is', x)
value of x is 2
>>> def saySomething(msg, times = 1):
...     print(msg * times)
... 
>>> saySomething('Oh')
Oh
>>> saySomething('Oh', 10)
OhOhOhOhOhOhOhOhOhOh
>>> def func_key(a, b = 5, c = 10):
...     print('a is', a, 'and b is', b, 'and c is', c)
... 
>>> func_key(3, 7)
a is 3 and b is 7 and c is 10
>>> func_key(25, c = 24)
a is 25 and b is 5 and c is 24
>>> func_key(c = 50, a = 100)
a is 100 and b is 5 and c is 50
>>> def maximum(x, y):
...     if x > y:
...         return x
...     else:
...         return y
... 
>>> maximum(3, 7)
7
>>> maximum(100, 7)
100
>>> def someFunction():
...     pass
... 
>>> if None == someFunction():
...     print('OK')
... 
OK
>>> import os
>>> os.system('clear')
>>> def printMax(x, y):
...     '''
...     Prints the maximum of two numbers.
...     The two values must be integers.
...     Now the \'DocStrings\' is over.
...     '''
...     if x > y:
...         print(x)
...     else:
...         print(y)
... 
>>> printMax(100, 20)
100
>>> print(printMax.__doc__)

    Prints the maximum of two numbers.
    The two values must be integers.
    Now the 'DocStrings' is over.
    
>>> 
>>> help(printMax)
 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值