| ���� Python �̳� | ��15�� ����Python������ | |
|---|---|---|
| ��һҳ | �ں����н���Ԫ����б� | ��һҳ |
��Ҫʹ��������Ԫ����ֵ���ʽ�IJ�����ʱ����һ������ķ��������ֱ�ʹ��*��**ǰ�����ַ����ں�����Ҫ��ȡ�ɱ������IJ�����ʱ���ر����á�
>>> def powersum(power, *args):
... '''Return the sum of each argument raised to specified power.'''
... total = 0
... for i in args:
... total += pow(i, power)
... return total
...
>>> powersum(2, 3, 4)
25
>>> powersum(2, 10)
100
������args����ǰ��*ǰ�����ж���ĺ�������������Ϊһ��Ԫ��洢��args�С����ʹ�õ���**ǰ������IJ�����ᱻ��Ϊ��һ���ֵ�ļ�/ֵ�ԡ�
| ��һҳ | ��һ�� | ��һҳ |
|---|---|---|
| �б��ۺ� | ��ҳ | lambda��ʽ |