Loading Mastering Python - Networking and Security - Working Files/Chapter 1/No Work Files.rtf 0 → 100755 +7 −0 Changes for Mastering Python - Networking and Security - Working Files/Chapter 1/No Work Files.rtf: 7 added lines, 0 removed lines. Original line number Diff line number Diff line {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural \f0\fs24 \cf0 No work files for this lesson...} No newline at end of file Mastering Python - Networking and Security - Working Files/Chapter 2/Conditionals.py 0 → 100755 +14 −0 Changes for Mastering Python - Networking and Security - Working Files/Chapter 2/Conditionals.py: 14 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/python3 __author__ = 'kilroy' # (c) 2014, WasHere Consulting, Inc. # Written for Infinite Skills # input is a string unless converted x = int(input("Give me a number ")) if (x < 1): print("Too little") elif (x >= 1 and x <= 10): print("Just about right") else: print("Too high") Mastering Python - Networking and Security - Working Files/Chapter 2/Exceptions.py 0 → 100755 +16 −0 Changes for Mastering Python - Networking and Security - Working Files/Chapter 2/Exceptions.py: 16 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/python3 __author__ = 'kilroy' # (c) 2014, WasHere Consulting, Inc. # Written for Infinite Skills try: fhandle = open("myfile", "w") fhandle.write("This is some data to dump into the file") print("Wrote some data to the file") except IOError as e: print("Exception caught: Unable to write to myfile ", e) except Exception as e: print("Another error occurred ", e) else: print("File written to successfully") fhandle.close() Mastering Python - Networking and Security - Working Files/Chapter 2/Loops.py 0 → 100755 +22 −0 Changes for Mastering Python - Networking and Security - Working Files/Chapter 2/Loops.py: 22 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/python3 __author__ = 'kilroy' name=input("What is your name? ") # for loop ... range creates a list for i in range(1,10): print (name, i) # while loop using break x=0 while True: print (x) x=x+1 if (x==15): break # for loop using a list mylist=['lions', 'tigers', 'bears', 'ohmy'] for i in mylist: print(i) Mastering Python - Networking and Security - Working Files/Chapter 2/ParsingArgs.py 0 → 100755 +17 −0 Changes for Mastering Python - Networking and Security - Working Files/Chapter 2/ParsingArgs.py: 17 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/python3 __author__ = 'kilroy' # (c) 2014, WasHere Consulting, Inc. # Written for Infinite Skills import argparse parser = argparse.ArgumentParser(description="This is our description") parser.add_argument('-i', type=str, help="This is the help you get to describe the parameter", required=True) parser.add_argument('-o', type=str, help="This is optional", required=False) # cmdargs ends up being a dictionary/hash cmdargs = parser.parse_args() # access the parameter based on the flag ivar = cmdargs.i print(ivar) Loading
Mastering Python - Networking and Security - Working Files/Chapter 1/No Work Files.rtf 0 → 100755 +7 −0 Changes for Mastering Python - Networking and Security - Working Files/Chapter 1/No Work Files.rtf: 7 added lines, 0 removed lines. Original line number Diff line number Diff line {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural \f0\fs24 \cf0 No work files for this lesson...} No newline at end of file
Mastering Python - Networking and Security - Working Files/Chapter 2/Conditionals.py 0 → 100755 +14 −0 Changes for Mastering Python - Networking and Security - Working Files/Chapter 2/Conditionals.py: 14 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/python3 __author__ = 'kilroy' # (c) 2014, WasHere Consulting, Inc. # Written for Infinite Skills # input is a string unless converted x = int(input("Give me a number ")) if (x < 1): print("Too little") elif (x >= 1 and x <= 10): print("Just about right") else: print("Too high")
Mastering Python - Networking and Security - Working Files/Chapter 2/Exceptions.py 0 → 100755 +16 −0 Changes for Mastering Python - Networking and Security - Working Files/Chapter 2/Exceptions.py: 16 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/python3 __author__ = 'kilroy' # (c) 2014, WasHere Consulting, Inc. # Written for Infinite Skills try: fhandle = open("myfile", "w") fhandle.write("This is some data to dump into the file") print("Wrote some data to the file") except IOError as e: print("Exception caught: Unable to write to myfile ", e) except Exception as e: print("Another error occurred ", e) else: print("File written to successfully") fhandle.close()
Mastering Python - Networking and Security - Working Files/Chapter 2/Loops.py 0 → 100755 +22 −0 Changes for Mastering Python - Networking and Security - Working Files/Chapter 2/Loops.py: 22 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/python3 __author__ = 'kilroy' name=input("What is your name? ") # for loop ... range creates a list for i in range(1,10): print (name, i) # while loop using break x=0 while True: print (x) x=x+1 if (x==15): break # for loop using a list mylist=['lions', 'tigers', 'bears', 'ohmy'] for i in mylist: print(i)
Mastering Python - Networking and Security - Working Files/Chapter 2/ParsingArgs.py 0 → 100755 +17 −0 Changes for Mastering Python - Networking and Security - Working Files/Chapter 2/ParsingArgs.py: 17 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/python3 __author__ = 'kilroy' # (c) 2014, WasHere Consulting, Inc. # Written for Infinite Skills import argparse parser = argparse.ArgumentParser(description="This is our description") parser.add_argument('-i', type=str, help="This is the help you get to describe the parameter", required=True) parser.add_argument('-o', type=str, help="This is optional", required=False) # cmdargs ends up being a dictionary/hash cmdargs = parser.parse_args() # access the parameter based on the flag ivar = cmdargs.i print(ivar)