diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/PythonforCybersecurity-example.iml b/.idea/PythonforCybersecurity-example.iml new file mode 100644 index 0000000..d859cb1 --- /dev/null +++ b/.idea/PythonforCybersecurity-example.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..c063f29 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2e2bf2c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ShoppingList.txt b/ShoppingList.txt index 27409dd..57cfe2e 100644 --- a/ShoppingList.txt +++ b/ShoppingList.txt @@ -2,4 +2,6 @@ Milk Break Bananas Eggs - +Apples +Tomatoes +Cake \ No newline at end of file diff --git a/end/CH02/HelloWorld.py b/end/CH02/HelloWorld.py index 205893c..f33fdce 100755 --- a/end/CH02/HelloWorld.py +++ b/end/CH02/HelloWorld.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 # A simple "Hello World" script in python -# Created by Ed Goad, 2/3/2021 -print("Hello World") \ No newline at end of file +# Created by Quentin Athula, 3/8/2025 + +your_name = input("what is your name? ") +print("Hello {0}".format(your_name)) diff --git a/end/CH02/HelloWorld2.py b/end/CH02/HelloWorld2.py index 0dccc6c..1213c85 100755 --- a/end/CH02/HelloWorld2.py +++ b/end/CH02/HelloWorld2.py @@ -1,6 +1,11 @@ #!/usr/bin/env python3 # A simple "Hello World" script in python with Inputs -# Created by Ed Goad, 2/3/2021 +# Created by Quentin Athula, 3/8/2025 your_name = input("What is your name? ") print("Hello {0}".format(your_name)) +print(f"Hello {your_name}") +print("Hello " + your_name) +print("Hello", your_name) +message = "Hello" + " " + your_name +print(message) diff --git a/end/CH02/SimpleCalculator.py b/end/CH02/SimpleCalculator.py index 4580dc3..2d1380a 100755 --- a/end/CH02/SimpleCalculator.py +++ b/end/CH02/SimpleCalculator.py @@ -1,14 +1,14 @@ -#!/usr/bin/env python3 -# A simple calculator to show math and conditionals -# Created by Ed Goad, 2/3/2021 +#!/user/bin/env python3 +# A simple calculator script in python +# Created by Quentin Athula, 3/9/2025 -# Get inputs first -# Note we are casting the numbers as "float", we could also do "int" +# Get input from the user +# Note we are casting the numbers as "float", we could also cast them as "int" first_num = float(input("What is the first number: ")) activity = input("What activity? ( + - * / ) ") second_num = float(input("What is the second number: ")) -# depending on the selected activity, perform an action +# depending on the selected activity, perform the calculation if activity == "+": print(first_num + second_num) if activity == "-": @@ -17,3 +17,4 @@ print(first_num * second_num) if activity == "/": print(first_num / second_num) + diff --git a/end/CH03/pinger1.py b/end/CH03/pinger1.py index a21dab0..cbc514b 100755 --- a/end/CH03/pinger1.py +++ b/end/CH03/pinger1.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 +#!/usr/bin/venv python3 # First example of pinging from Python -# By Ed Goad -# 2/27/2021 +# By Quentin Athula +# 3/15/2025 # import necessary Python modules import platform diff --git a/end/CH03/pinger2.py b/end/CH03/pinger2.py index 17f4eed..f16d0b5 100755 --- a/end/CH03/pinger2.py +++ b/end/CH03/pinger2.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python3 +#!/usr/bin/venv python3 # Second example of pinging from Python -# By Ed Goad -# 2/27/2021 +# By Quentin Athula +# 3/15/2025 # import necessary Python modules import platform @@ -9,11 +9,11 @@ # Assign IP to ping to a variable ip = "127.0.0.1" -# Determine the currrent OS -currrent_os = platform.system().lower() -if currrent_os == "windows": - # Build our ping command for Windows - ping_cmd = f"ping -n 1 -w 2 {ip} > nul" +# Determine the current OS +current_os = platform.system().lower() +if current_os == "darwin": + # Build our ping command for darwin + ping_cmd = f"ping -n 1 -w 2 {ip} > /dev/null 2>&1" else: # Build our ping command for other OSs ping_cmd = f"ping -c 1 -w 2 {ip} > /dev/null 2>&1" diff --git a/end/CH03/pinger3.py b/end/CH03/pinger3.py index 4f4d141..60e18e9 100755 --- a/end/CH03/pinger3.py +++ b/end/CH03/pinger3.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # Third example of pinging from Python -# By Ed Goad -# 2/27/2021 +# By Quentin Athula +# 3/16/2025 # import necessary Python modules import platform @@ -9,14 +9,14 @@ # Define the prefix to begin pinging ip_prefix = "192.168.0." -# Determine the currrent OS -currrent_os = platform.system().lower() +# Determine the current OS +current_os = platform.system().lower() # Loop from 0 - 254 for final_octet in range(254): # Assign IP to ping to a variable # Adding 1 to final_octet because loop starts at 0 ip = ip_prefix + str(final_octet + 1) - if currrent_os == "windows": + if current_os == "windows": # Build our ping command for Windows ping_cmd = f"ping -n 1 -w 2 {ip} > nul" else: diff --git a/start/CH02/HelloWorld.py b/start/CH02/HelloWorld.py index 88eb615..d39c824 100755 --- a/start/CH02/HelloWorld.py +++ b/start/CH02/HelloWorld.py @@ -1,3 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/.venv python3 # A simple "Hello World" script in python -# Created \ No newline at end of file +# Created by Quentin Athula 3/16/2025 +print("hello world") \ No newline at end of file diff --git a/start/CH02/HelloWorld1.py b/start/CH02/HelloWorld1.py new file mode 100644 index 0000000..532dd55 --- /dev/null +++ b/start/CH02/HelloWorld1.py @@ -0,0 +1,4 @@ +#!/user/bin/.venv/ python3 +# A sample "Check that the IDLE is working" script in python +# Created by Quentin Athula 3/22/2025 +print("This is a sample to check that the IDE is working") \ No newline at end of file diff --git a/start/CH02/HelloWorld2.py b/start/CH02/HelloWorld2.py index 1072d14..cacc939 100755 --- a/start/CH02/HelloWorld2.py +++ b/start/CH02/HelloWorld2.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 # A simple "Hello World" script in python with Inputs -# Created +# Created by Quentin Athula 3/22/2025 + +your_name = input("What is your name? ") +print("Hello {0} ".format(your_name)) + -# Suggestion, build out 1 line at a time -# Once multiple print statemetns exist, put a breakpoint at first print line -# Then walk through as an example of "debugging" diff --git a/start/CH02/HelloWorld3.py b/start/CH02/HelloWorld3.py index decd537..4b0b02f 100644 --- a/start/CH02/HelloWorld3.py +++ b/start/CH02/HelloWorld3.py @@ -1,3 +1,11 @@ #!/usr/bin/env python3 # A more complex "Hello World" script in python with Inputs -# Created +# Created by Quentin Athula 3/22/2025 + +your_name = input("What is your name? ") +print("Hello {0} ".format(your_name)) +print(f"Hello {your_name}") +print("Hello" + your_name) +print("Hello", your_name) +message = "Hello" + " " + your_name +print(message) diff --git a/start/CH03/pinger1.py b/start/CH03/pinger1.py index 6af65f6..d4e5ba9 100755 --- a/start/CH03/pinger1.py +++ b/start/CH03/pinger1.py @@ -1,3 +1,17 @@ #!/usr/bin/env python3 # First example of pinging from Python -# By \ No newline at end of file +# By Quentin Athula +# 4/22/2025 + +# import necessary python modules +import platform +import os + +# Assign IP address to ping to a variable +ip = "127.0.0.1" +# Build the command to ping the IP address +ping_cmd = f"ping -c 1 -w 2 {ip} > /dev/null 2>&1" +# Execute command and capture exit code +exit_code = os.system(ping_cmd) +# print the result to the console +print(exit_code) \ No newline at end of file diff --git a/start/CH03/pinger2.py b/start/CH03/pinger2.py index c80c993..eda325a 100755 --- a/start/CH03/pinger2.py +++ b/start/CH03/pinger2.py @@ -1,3 +1,24 @@ -#!/usr/bin/env python3 -# Second example of pinging from Python -# By \ No newline at end of file +#!/user/bin/.venv/ python3 +# A second example of pinging from python +# Created by Quentin athula +# 4/22/2025 + +# import necessary python modules +import platform +import os + +# Assign IP address to ping to a variable +ip = "127.0.0.1" +# Determine the current operating system +current_os = platform.system() . lower() +if current_os == "windows": + # Build our ping command for windows + ping_cmd = f"ping -n 1 -w 2 {ip} > nul" +else: + # Build our ping command for other operating systems + ping_cmd = f"ping -c 1 -w 2 {ip} > /dev/null 2>&1" + +# Execute command and capture exit code +exit_code = os.system(ping_cmd) +# print the result to the console +print(exit_code) \ No newline at end of file diff --git a/start/CH03/pinger3.py b/start/CH03/pinger3.py index 8ca3629..618c7b3 100755 --- a/start/CH03/pinger3.py +++ b/start/CH03/pinger3.py @@ -1,3 +1,30 @@ -#!/usr/bin/env python3 +#!/user/bin/.vnv/ python3 # Third example of pinging from Python -# By \ No newline at end of file +# By Quentin Athula +# 4/22/2025 + +# import necessary python modules +import platform +import os + +# Define a function to ping an IP address +ip_prefix = "192.168.1." +# determine the current operating system +current_os = platform.system(). lower() +# Loop from 0 - 254 +for final_octet in range(254): + # Assign IP to ping to a variable + # Adding 1 to final_octet because loop starts at 0 + ip = ip_prefix + str(final_octet + 1) + if current_os == "windows": + # Build our ping command for windows + ping_cmd = f"ping -n 1 -w 2 {ip} > nul" + else: + # Build our ping command for other operating systems + ping_cmd = f"ping -c 1 -w 2 {ip} > /dev/null 2>&1" + + # Execute command and capture exit code + exit_code = os.system(ping_cmd) + # print results to console only if successful + if exit_code == 0: + print("{0} is online" .format(ip)) diff --git a/start/CH03/pinger4.py b/start/CH03/pinger4.py index 3d174a0..b622de8 100755 --- a/start/CH03/pinger4.py +++ b/start/CH03/pinger4.py @@ -1,3 +1,38 @@ #!/usr/bin/env python3 # Fourth example of pinging from Python -# By \ No newline at end of file +# By Quentin athula +# 4/22/2025 + +# import necessary python modules +import platform +import os + +def ping_host(ip): + # Determine the current operating system + current_os = platform.system().lower() + if current_os == "windows": + # Build our ping command for windows + ping_cmd = f"ping -n 1 -w 2 {ip} > nul" + else: + # Build our ping command for other operating systems + ping_cmd = f"ping -c 1 -w 2 {ip} > /dev/null 2>&1" + + # Execute command and capture exit code + exit_code = os.system(ping_cmd) + return exit_code + +# Define the prefix to begin pinging +ip_prefix = "192.168.1." + +# loop from 0 - 254 +for final_octet in range(254): + # Assign IP to ping to a variable + # Adding 1 to final_octet because loop starts at 0 + ip = ip_prefix + str(final_octet + 1) + + # call the ping_host function and capture the return value + exit_code = ping_host(ip) + + # print results to console only if successful + if exit_code == 0: + print("{0} is online" .format(ip))