summaryrefslogtreecommitdiff
path: root/comp/hw
diff options
context:
space:
mode:
authorstandenboy <standenboy@StandenboyLAP.lan>2024-01-10 13:44:03 +0000
committerstandenboy <standenboy@StandenboyLAP.lan>2024-01-10 13:44:03 +0000
commit5fbd145a080da6c02a15cd4f78fab940ce046b09 (patch)
tree11dbd1ece3de65b24e78535f32bc262005d5c2bf /comp/hw
parentf267b783b87353a70eacf786e940d5d480c4da03 (diff)
added 109 homework
Diffstat (limited to 'comp/hw')
-rw-r--r--comp/hw/109/grid.py11
-rw-r--r--comp/hw/109/hangman.py19
-rw-r--r--comp/hw/109/matrix.py10
-rw-r--r--comp/hw/109/range.py8
-rw-r--r--comp/hw/109/words.py8
5 files changed, 56 insertions, 0 deletions
diff --git a/comp/hw/109/grid.py b/comp/hw/109/grid.py
new file mode 100644
index 0000000..b418aeb
--- /dev/null
+++ b/comp/hw/109/grid.py
@@ -0,0 +1,11 @@
+import sys
+for i in range(1,11):
+ for j in range(1,11):
+ num = i*j
+ if i == j:
+ sys.stdout.write("* ")
+ elif i + j == 11:
+ sys.stdout.write("$ ")
+ else:
+ sys.stdout.write(f"{str(j*i)} ")
+ print()
diff --git a/comp/hw/109/hangman.py b/comp/hw/109/hangman.py
new file mode 100644
index 0000000..9749838
--- /dev/null
+++ b/comp/hw/109/hangman.py
@@ -0,0 +1,19 @@
+import random
+words = ["hello", "there", "this", "is", "a", "line"]
+
+word = words[random.randint(0,len(words)-1)]
+
+print(len(word))
+
+for i in range(5):
+ letter = input("guess a letter: ")
+ if letter in word:
+ print("yes")
+ else:
+ print("no")
+
+guess = input("guess the word: ")
+if guess == word:
+ print("you win")
+else:
+ print("!(you win)")
diff --git a/comp/hw/109/matrix.py b/comp/hw/109/matrix.py
new file mode 100644
index 0000000..3e95ff2
--- /dev/null
+++ b/comp/hw/109/matrix.py
@@ -0,0 +1,10 @@
+matrix = [[1,2,3],[4,5,6],[7,8,9]]
+
+num = int(input("number: "))
+
+for i in matrix:
+ for j in i:
+ if j == num:
+ print("true")
+ exit(0)
+print("false")
diff --git a/comp/hw/109/range.py b/comp/hw/109/range.py
new file mode 100644
index 0000000..49b3a7a
--- /dev/null
+++ b/comp/hw/109/range.py
@@ -0,0 +1,8 @@
+import sys
+
+num1 = int(input("num 1: "))
+num2 = int(input("num 2: "))
+
+for i in range(num1, num2+1):
+ sys.stdout.write(f" {str(i)}")
+print()
diff --git a/comp/hw/109/words.py b/comp/hw/109/words.py
new file mode 100644
index 0000000..516275f
--- /dev/null
+++ b/comp/hw/109/words.py
@@ -0,0 +1,8 @@
+import random
+
+words = ["hello", "there", "this", "is", "a", "line"]
+
+for i in range(6):
+ word = words[random.randint(0,len(words)-1)]
+ print(word)
+ words.remove(word)