TristanSld

functions with default arguments

Feb 14th, 2014
63
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. def us(sayi, u=2):
  5.     print sayi ** u
  6. us(3) #varsayılan değer 2
  7. us(3,3)
  8. print "\n"
  9. def bol(bolunen, bolen, hassas=True):
  10.     sonuc = bolunen / float(bolen)
  11.     if hassas == True:
  12.         print float(sonuc)
  13.     if hassas == False:
  14.         print int(sonuc)
  15. bol(5,2) #varsayılan değer True
  16. bol(5,2,False)
RAW Paste Data