diff options
Diffstat (limited to 'comp')
-rw-r--r-- | comp/hw/109/grid.py | 11 | ||||
-rw-r--r-- | comp/hw/109/hangman.py | 19 | ||||
-rw-r--r-- | comp/hw/109/matrix.py | 10 | ||||
-rw-r--r-- | comp/hw/109/range.py | 8 | ||||
-rw-r--r-- | comp/hw/109/words.py | 8 | ||||
-rw-r--r-- | comp/work/16/vectors | 11 |
6 files changed, 67 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) diff --git a/comp/work/16/vectors b/comp/work/16/vectors new file mode 100644 index 0000000..1c2fd14 --- /dev/null +++ b/comp/work/16/vectors @@ -0,0 +1,11 @@ +circle.center 5, 15 +circle.radius 4 +circle.fill red +circle.outline yellow +circle.weight 3pt + +square.posistion 10, 18 +square.width 5 +square.height 5 +square.fill red + |