summaryrefslogtreecommitdiff
path: root/comp/hw/113
diff options
context:
space:
mode:
authorstandenboy <you@example.com>2024-02-28 20:07:53 +0000
committerstandenboy <you@example.com>2024-02-28 20:07:53 +0000
commit647d3b98658ddae66882badc508633c9a33eff32 (patch)
treefb8869aecac61b31b05b350d486e46aed54ef9a9 /comp/hw/113
parente4864bf1cd9e192eb54e492aaf02a397e143539c (diff)
added homework
Diffstat (limited to 'comp/hw/113')
-rw-r--r--comp/hw/113/1.py11
-rw-r--r--comp/hw/113/2.py42
-rw-r--r--comp/hw/113/items5
3 files changed, 58 insertions, 0 deletions
diff --git a/comp/hw/113/1.py b/comp/hw/113/1.py
new file mode 100644
index 0000000..d0e743b
--- /dev/null
+++ b/comp/hw/113/1.py
@@ -0,0 +1,11 @@
+import random
+serverPortNames = [["http", 80], ["ftp control", 21], ["ftp data", 20], ["https", 443], ["pop3", 110], ["smtp", 25], ["ssh (the best one)", 22]]
+
+while len(serverPortNames) != 0:
+ randNum = random.randint(0, len(serverPortNames) - 1)
+ ans = int(input(f"what is the port number of {serverPortNames[randNum][0]}: "))
+ if ans == serverPortNames[randNum][1]:
+ print("you did it!")
+ serverPortNames.pop(randNum)
+ else:
+ print("you got it wrong, sorry")
diff --git a/comp/hw/113/2.py b/comp/hw/113/2.py
new file mode 100644
index 0000000..cdcc622
--- /dev/null
+++ b/comp/hw/113/2.py
@@ -0,0 +1,42 @@
+toWrite = """Sword,5
+Mace,3
+Warhammer,8
+Shield,1
+Spear,6
+"""
+
+def getLowest(list):
+ lowest = 1000
+ for i in list:
+ if i < lowest:
+ lowest = i
+ return lowest
+
+f = open("./items", "w")
+
+f.write(toWrite)
+
+f.close()
+
+f = open("./items", "r")
+
+items = []
+for i in f.readlines():
+ tmp = []
+ tmp.append(i.split(",")[0])
+ tmp.append(int(i.split(",")[1].strip("\n ")))
+ items.append(tmp)
+
+amounts = []
+for i in items:
+ amounts.append(i[1])
+sorted = []
+
+for x in range(len(items)):
+ for i in items:
+ if i[1] == getLowest(amounts):
+ sorted.append(i[0])
+ items.remove(i)
+ amounts.remove(getLowest(amounts))
+
+print(*sorted, sep=" ")
diff --git a/comp/hw/113/items b/comp/hw/113/items
new file mode 100644
index 0000000..6b115e6
--- /dev/null
+++ b/comp/hw/113/items
@@ -0,0 +1,5 @@
+Sword,5
+Mace,3
+Warhammer,8
+Shield,1
+Spear,6