Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

اسلاید اول جلسه پنجم کلاس پایتون برای هکرهای قانونی

278 views

Published on

جلسه پنجم و اسلاید شماره یک کلاس پایتون برای هکرهای قانونی
این جلسه در مورد
فانکشن ها در پایتون بحث شد

Published in: Education, Technology
  • Be the first to comment

اسلاید اول جلسه پنجم کلاس پایتون برای هکرهای قانونی

  1. 1. Python for Ethical Hackers Mohammad reza Kamalifard
  2. 2. Python Language Essentials Part 5 : • Functions
  3. 3. Functions Functions allow sections of code to be grouped better as per functionality
  4. 4. Functions def function(arg1,arg2=default,..): do_something return value
  5. 5. Functions >>> def print5times(input): ... for count in range(0,5): ... print input ... >>> print5times('Hello') Hello Hello Hello Hello Hello
  6. 6. >>> print5times('Javad') Javad Javad Javad Javad Javad >>> print5times('Hello, World!') Hello, World! Hello, World! Hello, World! Hello, World! Hello, World! >>>
  7. 7. >>> def mul2(num): return num * 2 >>>mul2(3) 6 >>>mul2(6) 12 >>>mul2(4) 8
  8. 8. $ vim testargv.py #!/usr/bin/env python import sys print sys.argv ~ ~
  9. 9. $ chmod a+x testargv.py $ ./testargv.py ['./testargv.py'] $ $ ./testargv.py salam ['./testargv.py', 'salam'] $ $ $./testargv.py -h 199 --app firefox ['./testargv.py', '-h', '199', '--app', 'firefox'] $
  10. 10. $ vim function.py #!/usr/bin/env python import sys def print5times(content_to_print): for count in range(0,5): print content_to_print print5times(sys.argv[1]) ~ ~
  11. 11. $ ./function.py salam salam salam salam salam salam $ $ ./function.py salam hamid salam salam salam salam salam $ $ ./function.py 'salam hamid' salam hamid salam hamid salam hamid salam hamid salam hamid
  12. 12. ©2013 Mohammad Reza Kamalifard. This work is licensed under the Creative Commons Attribution-NoDerivs 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/3.0/ Copyright 2013 Mohammad reza Kamalifard. All rights reserved.

×