summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstandenboy <standenboy@StandenboyLAP.lan>2024-01-25 10:57:10 +0000
committerstandenboy <standenboy@StandenboyLAP.lan>2024-01-25 10:57:10 +0000
commiteb1a5582181bf3188f30d665a295321d36bdc795 (patch)
tree01c10676436a51a03fa53519fe8572f5d31abb1c
parent9e83a3046472e598be3f5a9b7d104f97a97ff36a (diff)
did the cover work
-rw-r--r--comp/work/21/minesweeper.py66
-rw-r--r--comp/work/21/money.py3
-rw-r--r--comp/work/21/mysum.py14
-rw-r--r--comp/work/21/names.py15
-rw-r--r--comp/work/21/results.py22
-rw-r--r--comp/work/21/timestables.py10
6 files changed, 130 insertions, 0 deletions
diff --git a/comp/work/21/minesweeper.py b/comp/work/21/minesweeper.py
new file mode 100644
index 0000000..2a6be22
--- /dev/null
+++ b/comp/work/21/minesweeper.py
@@ -0,0 +1,66 @@
+import random
+grid = [
+ [0,0,0,0,0,0],
+ [0,0,0,0,0,0],
+ [0,0,0,0,0,0],
+ [0,0,0,0,0,0],
+ [0,0,0,0,0,0],
+ [0,0,0,0,0,0],
+ ]
+
+def getValidPos(text):
+ inp = -1
+ while inp < 1 or inp > 6:
+ inp = int(input(text))
+ return inp
+
+def printGrid():
+ for i in grid:
+ for j in i:
+ if j == "B":
+ print("0", end = " ")
+ else:
+ print(j, end = " ")
+ print()
+
+def placeBombs(amount):
+ for i in range(amount):
+ grid[random.randint(0,5)][random.randint(0,5)] = "B"
+
+def isMineNear(row, collumn):
+ row = row - 1
+ collumn = collumn - 1
+ try:
+ if grid[row][collumn+1] == "B":
+ print("a bomb is near")
+ elif grid[row][collumn-1] == "B":
+ print("a bomb is near")
+ elif grid[row+1][collumn] == "B":
+ print("a bomb is near")
+ elif grid[row-1][collumn] == "B":
+ print("a bomb is near")
+ elif grid[row+1][collumn+1] == "B":
+ print("a bomb is near")
+ elif grid[row-1][collumn-1] == "B":
+ print("a bomb is near")
+ elif grid[row-1][collumn+1] == "B":
+ print("a bomb is near")
+ elif grid[row+1][collumn-1] == "B":
+ print("a bomb is near")
+ except:
+ pass
+
+
+placeBombs(10)
+
+score = 0
+while True:
+ printGrid()
+ row = getValidPos("row: ")
+ collumn = getValidPos("collumn: ")
+ if grid[row-1][collumn-1] == "B":
+ print("you blew up, your score was", score)
+ break
+ grid[row-1][collumn-1] = "G"
+ score = score + 1
+ isMineNear(row, collumn)
diff --git a/comp/work/21/money.py b/comp/work/21/money.py
new file mode 100644
index 0000000..55e7ecd
--- /dev/null
+++ b/comp/work/21/money.py
@@ -0,0 +1,3 @@
+money = float(input("amount of money: "))
+
+print(f"${money:.2f}")
diff --git a/comp/work/21/mysum.py b/comp/work/21/mysum.py
new file mode 100644
index 0000000..fdbb0bb
--- /dev/null
+++ b/comp/work/21/mysum.py
@@ -0,0 +1,14 @@
+nums = [[3,7,12,5],[8,4,1,6],[15,0,2,6]]
+
+def mysum(list):
+ total = 0
+ for i in list:
+ total = total + i
+ return total
+
+
+total = 0
+for i in nums:
+ total = total + mysum(i)
+
+print(total)
diff --git a/comp/work/21/names.py b/comp/work/21/names.py
new file mode 100644
index 0000000..9c322b9
--- /dev/null
+++ b/comp/work/21/names.py
@@ -0,0 +1,15 @@
+names = []
+for i in range(5):
+ name = input("name: ")
+ names.append(name)
+
+f = open("names.txt", "r+")
+for i in names:
+ i = i+"\n"
+ f.write(i)
+
+nameToSearch = input("name to search: ")
+for i in f.readlines():
+ if i.split("\n")[0] == nameToSearch:
+ print("name found")
+ break
diff --git a/comp/work/21/results.py b/comp/work/21/results.py
new file mode 100644
index 0000000..bfd2d2f
--- /dev/null
+++ b/comp/work/21/results.py
@@ -0,0 +1,22 @@
+results = []
+
+more = "yes"
+
+while more.lower() == "yes":
+ result = 0
+ tmp = []
+ while True:
+ result = int(input("result: "))
+ if result == -1:
+ break
+ if result < 0:
+ print("invalid input")
+ elif result > 100:
+ print("invalid input")
+ else:
+ tmp.append(result)
+ results.append(tmp)
+ more = input("add results for another student? ")
+
+for i in range(len(results)):
+ print("student",i+1,"got: ", *results[i])
diff --git a/comp/work/21/timestables.py b/comp/work/21/timestables.py
new file mode 100644
index 0000000..0e4c07e
--- /dev/null
+++ b/comp/work/21/timestables.py
@@ -0,0 +1,10 @@
+for i in range(1,12):
+ for j in range(1,12):
+ num = i * j
+ if num < 10:
+ print(f"00{num} ", end="")
+ elif num < 100:
+ print(f"0{num} ", end="")
+ else:
+ print(f"{num} ", end="")
+ print()