diff options
Diffstat (limited to 'python/personal')
| -rw-r--r-- | python/personal/Garry.txt | 1 | ||||
| -rw-r--r-- | python/personal/__pycache__/pandas.cpython-311.pyc | bin | 0 -> 347 bytes | |||
| -rw-r--r-- | python/personal/me learning python.py | 122 | ||||
| -rw-r--r-- | python/personal/pandas.py | 8 | ||||
| -rw-r--r-- | python/personal/password.py | 8 | ||||
| -rw-r--r-- | python/personal/peepee.py | 2 | ||||
| -rw-r--r-- | python/personal/ping an address.py | 26 | ||||
| -rw-r--r-- | python/personal/plt.py | 13 |
8 files changed, 180 insertions, 0 deletions
diff --git a/python/personal/Garry.txt b/python/personal/Garry.txt new file mode 100644 index 0000000..6b4d58a --- /dev/null +++ b/python/personal/Garry.txt @@ -0,0 +1 @@ +obamna diff --git a/python/personal/__pycache__/pandas.cpython-311.pyc b/python/personal/__pycache__/pandas.cpython-311.pyc Binary files differnew file mode 100644 index 0000000..d9e3dae --- /dev/null +++ b/python/personal/__pycache__/pandas.cpython-311.pyc diff --git a/python/personal/me learning python.py b/python/personal/me learning python.py new file mode 100644 index 0000000..6d0b629 --- /dev/null +++ b/python/personal/me learning python.py @@ -0,0 +1,122 @@ +# doing some things. +x = 5.79 +y = int(x) +print(y) + +# printing length of str name with len() function +name = " Nik is big poop face " +print(len(name)) + +# finding and printing index 1 if str name as var z +z = name[1] +print(z) + +# finding and printing index 2 through 5 of str name as var y +y = name[2:5] +print(y) + +# replacing all "N" in str name with "P", after stripping blank space from the ends with var.strip() +name = name.replace("N", "P") +print(name.strip()) + +# {} is a placeholder, used for int age here +age = 36 +txt = "My name is John, and I am {}" +print(txt.format(age)) + +# this is true, becuase int age is not empty (its an int, not nothing) +print(bool(age)) + +# this is false, because its an empty string (its nothing, not a string) +print(bool("")) + +# defining list body_parts, seeing if str "arm" is present in it, printing "hooray" if it is +body_parts = ["arm", "leg"] +if "arm" in body_parts: + print("hooray") + +### lists, bounded by [], can be modified. tuples, bounded by (), cannot. + +# changing index 0 of list body_parts from "arm" to "pooper" +body_parts[0] = "pooper" +print(body_parts[0]) + +# appending "head" to list body_parts, then printing +body_parts.append("head") +print(body_parts) + +# inserting str "butt" into index 3 of list body_parts +body_parts.insert(3, "butt") +print(body_parts) + +# printing index -1 (the last one) of body_parts +print(body_parts[-1]) + +# defining set computer_parts, and list more_computer_parts +computer_parts = {"SSD", "CPU", "GPU"} +more_computer_parts = ["RAM", "HDD", "AIO"] + +# updating computer_parts, with more_computer_parts, printing updated list +computer_parts.update(more_computer_parts) +print(computer_parts) + +# defining dict Truck, and its values +Truck = { + "model" : "Ranger", + "year" : 2010, + "make" : "Ford", + "displacement" : 4.0, + "transmission" : 5, + "drivetrain" : "4x4" +} + +# printing Trucks "displacement" value +print(Truck.get("displacement")) + +# changing displacement value of dict Truck to 2.8, printing the changed value +Truck["displacement"] = 2.8 +print(Truck.get("displacement")) + +# setting a value, "color" in dict Truck, printing Truck's "color" value, the str "blue" +Truck["color"] = "blue" +print(Truck.get("color")) + +# using the pop method to remove dict Truck's "transmission" value, printing the resulting dict +Truck.pop("transmission") +print(Truck) + +# this line was typed on my thinkpad X395 + +X = 20 +Y = 20 +Z = 30 + +# logical operator stuff +if X == Y: + print("yes") + +if X == Y and Y == Z: + print("yes") + +# while i < 6, add 1. once it reaches 6, stop adding, and print ("") +i = 1 +while i < 6: + print(i) + i += 1 +else: + + print("i is no longer less than 6") + +# defining poopfunction +def poopfunction(): + fruits = ["apple", "banana", "cherry", "Buthoal"] + for x in fruits: + if x == "apple": + print(x) + +# calling poopfunction +poopfunction() + +a = 2 +lambda a : a +print(a) diff --git a/python/personal/pandas.py b/python/personal/pandas.py new file mode 100644 index 0000000..6fbba83 --- /dev/null +++ b/python/personal/pandas.py @@ -0,0 +1,8 @@ +import numpy as np +import scipy.stats as s +import glob as glob # importing glob as glob +import pandas as p + + +x = 20 +print(x)
\ No newline at end of file diff --git a/python/personal/password.py b/python/personal/password.py new file mode 100644 index 0000000..5d45c99 --- /dev/null +++ b/python/personal/password.py @@ -0,0 +1,8 @@ +password = open('Garry.txt') +secret = password.read() +print("Password?") +query = input() +if query == secret: + print("correct!") +else: + print("NO NO THE ANSWER IS CUCUMBER")
\ No newline at end of file diff --git a/python/personal/peepee.py b/python/personal/peepee.py new file mode 100644 index 0000000..4a83f81 --- /dev/null +++ b/python/personal/peepee.py @@ -0,0 +1,2 @@ +you = "peepee" +print("you are a "+ you) diff --git a/python/personal/ping an address.py b/python/personal/ping an address.py new file mode 100644 index 0000000..6ae13c1 --- /dev/null +++ b/python/personal/ping an address.py @@ -0,0 +1,26 @@ +import subprocess +import platform + +hostname = "something" + +# ping parameters +# -c (count): number of packets to send +# -W (timeout): time to wait for a response, in seconds +ping_count = 5 +ping_timeout = 1 + +# determine the system type (Windows or Unix-based) +system = platform.system().lower() +if system == "windows": + ping_args = ["ping", "-n", str(ping_count), "-w", str(ping_timeout * 1000), hostname] +else: + ping_args = ["ping", "-c", str(ping_count), "-W", str(ping_timeout), hostname] + +# run the ping command +result = subprocess.run(ping_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + +# check if the ping was successful +if result.returncode == 0: + print(f"{hostname} is reachable.") +else: + print(f"{hostname} is unreachable.") diff --git a/python/personal/plt.py b/python/personal/plt.py new file mode 100644 index 0000000..c81fd3d --- /dev/null +++ b/python/personal/plt.py @@ -0,0 +1,13 @@ +import numpy as np +import matplotlib.pyplot as plt + +# Let's have our x values just be a count from 0 to 49. +var1 = np.arange(50) +print(var1) + +# And let's randomly generate some y values! +var2 = var1 + 10*np.random.randn(50) + +plt.scatter(var1,var2) + +plt.show() |
