From 4a95719d58a708ad55b1389631d6339047f786a0 Mon Sep 17 00:00:00 2001 From: standenboy Date: Fri, 15 Dec 2023 10:19:20 +0000 Subject: added existing work --- comp/work/1/areaCirc.py | 10 +++++ comp/work/1/areaRect.py | 14 ++++++ comp/work/1/calcVAT | 6 +++ comp/work/1/fahToCel | 5 +++ comp/work/10/railfence.py | 19 ++++++++ comp/work/11/area.py | 7 +++ comp/work/11/cinlinder.py | 6 +++ comp/work/11/isLetter.py | 7 +++ comp/work/11/numOfVowles.py | 8 ++++ comp/work/11/volume.py | 5 +++ comp/work/11/wage.py | 10 +++++ comp/work/12/__pycache__/valid.cpython-312.pyc | Bin 0 -> 1408 bytes comp/work/12/usingModdules.py | 3 ++ comp/work/12/valid.py | 60 +++++++++++++++++++++++++ comp/work/13/find_smallest.py | 9 ++++ comp/work/13/reverse_words.py | 6 +++ comp/work/13/task.py | 14 ++++++ comp/work/2/fstring.py | 4 ++ comp/work/2/pi.py | 2 + comp/work/2/shops.py | 25 +++++++++++ comp/work/2/syntaxError | 6 +++ comp/work/3/isIn.c | 19 ++++++++ comp/work/3/isSquare.py | 5 +++ comp/work/3/password.py | 6 +++ comp/work/3/year.py | 4 ++ comp/work/4/pythagorus | 6 +++ comp/work/4/sumAndMean | 6 +++ comp/work/5/567.py | 10 +++++ comp/work/5/name.py | 5 +++ comp/work/5/odd.py | 3 ++ comp/work/5/printCon | 5 +++ comp/work/5/wordCount.py | 12 +++++ comp/work/5/xTo.py | 2 + comp/work/6/5timesTable.py | 8 ++++ comp/work/6/cake.py | 8 ++++ comp/work/6/iceCream.py | 29 ++++++++++++ comp/work/7/dice.py | 26 +++++++++++ comp/work/7/famous.py | 26 +++++++++++ comp/work/7/friends.py | 7 +++ comp/work/7/input.py | 18 ++++++++ comp/work/8/ascii | Bin 0 -> 18376 bytes comp/work/8/ascii.c | 7 +++ comp/work/8/ascii_word | Bin 0 -> 18568 bytes comp/work/8/ascii_word.c | 11 +++++ comp/work/8/parity | Bin 0 -> 18376 bytes comp/work/8/parity.c | 34 ++++++++++++++ comp/work/9/scores.py | 21 +++++++++ comp/work/9/tanks.py | 10 +++++ 48 files changed, 514 insertions(+) create mode 100755 comp/work/1/areaCirc.py create mode 100755 comp/work/1/areaRect.py create mode 100755 comp/work/1/calcVAT create mode 100755 comp/work/1/fahToCel create mode 100755 comp/work/10/railfence.py create mode 100755 comp/work/11/area.py create mode 100755 comp/work/11/cinlinder.py create mode 100755 comp/work/11/isLetter.py create mode 100755 comp/work/11/numOfVowles.py create mode 100755 comp/work/11/volume.py create mode 100755 comp/work/11/wage.py create mode 100755 comp/work/12/__pycache__/valid.cpython-312.pyc create mode 100755 comp/work/12/usingModdules.py create mode 100755 comp/work/12/valid.py create mode 100755 comp/work/13/find_smallest.py create mode 100755 comp/work/13/reverse_words.py create mode 100755 comp/work/13/task.py create mode 100755 comp/work/2/fstring.py create mode 100755 comp/work/2/pi.py create mode 100755 comp/work/2/shops.py create mode 100755 comp/work/2/syntaxError create mode 100755 comp/work/3/isIn.c create mode 100755 comp/work/3/isSquare.py create mode 100755 comp/work/3/password.py create mode 100755 comp/work/3/year.py create mode 100755 comp/work/4/pythagorus create mode 100755 comp/work/4/sumAndMean create mode 100755 comp/work/5/567.py create mode 100755 comp/work/5/name.py create mode 100755 comp/work/5/odd.py create mode 100755 comp/work/5/printCon create mode 100755 comp/work/5/wordCount.py create mode 100755 comp/work/5/xTo.py create mode 100755 comp/work/6/5timesTable.py create mode 100755 comp/work/6/cake.py create mode 100755 comp/work/6/iceCream.py create mode 100755 comp/work/7/dice.py create mode 100755 comp/work/7/famous.py create mode 100755 comp/work/7/friends.py create mode 100755 comp/work/7/input.py create mode 100755 comp/work/8/ascii create mode 100755 comp/work/8/ascii.c create mode 100755 comp/work/8/ascii_word create mode 100755 comp/work/8/ascii_word.c create mode 100755 comp/work/8/parity create mode 100755 comp/work/8/parity.c create mode 100755 comp/work/9/scores.py create mode 100755 comp/work/9/tanks.py (limited to 'comp/work') diff --git a/comp/work/1/areaCirc.py b/comp/work/1/areaCirc.py new file mode 100755 index 0000000..5c5deac --- /dev/null +++ b/comp/work/1/areaCirc.py @@ -0,0 +1,10 @@ +import math + +radius = float(input("radius of the circle: ")) + +area = (math.pi) * (radius * radius) + +areaInPi = area / math.pi + +print("the area of a circle with a radius of", radius, "is", area, "(",areaInPi,"PI )") + diff --git a/comp/work/1/areaRect.py b/comp/work/1/areaRect.py new file mode 100755 index 0000000..e96af85 --- /dev/null +++ b/comp/work/1/areaRect.py @@ -0,0 +1,14 @@ +print("This program calculates the area of a rectangle") + +length = float(input("Type in the length : ")) + +width = float(input("Type in the width : ")) + +perimeter = (length * 2) + (width *2) + +area = length * width + +print("The area of the rectangle with a length of", length, "and a width of", width, "is", area) +print("The perimiter of the rectangle with a length of", length, "and a width of", width, "is", perimeter) + + diff --git a/comp/work/1/calcVAT b/comp/work/1/calcVAT new file mode 100755 index 0000000..bcebd93 --- /dev/null +++ b/comp/work/1/calcVAT @@ -0,0 +1,6 @@ +startingMoney = float(input("starting money: ")) + +endingMoney = startingMoney - (startingMoney * 0.2) +endingMoney = format(endingMoney, ".2f") + +print("you now have", endingMoney) diff --git a/comp/work/1/fahToCel b/comp/work/1/fahToCel new file mode 100755 index 0000000..e412c72 --- /dev/null +++ b/comp/work/1/fahToCel @@ -0,0 +1,5 @@ +inputTemp = float(input("Temprature in fahrenheit: ")) + +convertedTemp = (5 / 9) * (inputTemp - 32) + +print("the converted temp is", convertedTemp) diff --git a/comp/work/10/railfence.py b/comp/work/10/railfence.py new file mode 100755 index 0000000..c91d491 --- /dev/null +++ b/comp/work/10/railfence.py @@ -0,0 +1,19 @@ +string = "HELLO_THERE" +shift = 4 +hidden = [] +tmp = "" +for i in string: + if len(tmp) + 1 > shift: + hidden.append(tmp) + tmp = "" + tmp = tmp + i +if len(tmp) != 0: + hidden.append(tmp) +final = [] +for i in range(shift): + for j in hidden: + try: + final.append(j[i]) + except: + pass +print(final) diff --git a/comp/work/11/area.py b/comp/work/11/area.py new file mode 100755 index 0000000..c4e2359 --- /dev/null +++ b/comp/work/11/area.py @@ -0,0 +1,7 @@ +def area(length, height): + return length * height + +length = int(input("the length of the shape: ")) +height = int(input("the height of the shape: ")) + +print(area(length,height)) diff --git a/comp/work/11/cinlinder.py b/comp/work/11/cinlinder.py new file mode 100755 index 0000000..3fc1972 --- /dev/null +++ b/comp/work/11/cinlinder.py @@ -0,0 +1,6 @@ +import math + +def volume(height, radius): + return ((math.pi * radius**2) * height) + +print(volume(10, 3)) diff --git a/comp/work/11/isLetter.py b/comp/work/11/isLetter.py new file mode 100755 index 0000000..593ff5e --- /dev/null +++ b/comp/work/11/isLetter.py @@ -0,0 +1,7 @@ +import string +def isLetter(letter): + for i in list(string.ascii_lowercase): + if letter == i: + return True + return False +print(isLetter('1')) diff --git a/comp/work/11/numOfVowles.py b/comp/work/11/numOfVowles.py new file mode 100755 index 0000000..77ab199 --- /dev/null +++ b/comp/work/11/numOfVowles.py @@ -0,0 +1,8 @@ +def count(string): + counter = 0 + for i in string.lower(): + for j in ["a","e","i","o","u"]: + if i == j: + counter = counter + 1 + return counter +print(count("hello")) diff --git a/comp/work/11/volume.py b/comp/work/11/volume.py new file mode 100755 index 0000000..3963b4a --- /dev/null +++ b/comp/work/11/volume.py @@ -0,0 +1,5 @@ +def volume(x,y,z): + return x*y*z + + +print(volume(5,6,3)) diff --git a/comp/work/11/wage.py b/comp/work/11/wage.py new file mode 100755 index 0000000..4dbba7f --- /dev/null +++ b/comp/work/11/wage.py @@ -0,0 +1,10 @@ +def wage(hours, rate): + pay = 0 + for i in range(hours): + if i < 35: + pay = pay + rate + else: + pay = pay + (rate + (rate * 0.5)) + return pay + +print(wage(40, 10)) diff --git a/comp/work/12/__pycache__/valid.cpython-312.pyc b/comp/work/12/__pycache__/valid.cpython-312.pyc new file mode 100755 index 0000000..400cc75 Binary files /dev/null and b/comp/work/12/__pycache__/valid.cpython-312.pyc differ diff --git a/comp/work/12/usingModdules.py b/comp/work/12/usingModdules.py new file mode 100755 index 0000000..491ff3f --- /dev/null +++ b/comp/work/12/usingModdules.py @@ -0,0 +1,3 @@ +import valid + +print(valid.validName("lucas")) diff --git a/comp/work/12/valid.py b/comp/work/12/valid.py new file mode 100755 index 0000000..0f2e403 --- /dev/null +++ b/comp/work/12/valid.py @@ -0,0 +1,60 @@ +def validName(name): + valid = True + for letter in name: + if letter.upper() > "Z" or letter.upper() < "A": + if letter != "-" and letter != " ": + valid = False + return valid + +def validNumber(number): + try: + int(number) + except: + return False + return True + +def validYear(year): + year = int(year) + if year < 1900: + return False + if year > 2099: + return False + return True + +def validMonth(month): + month = int(month) + if month <= 0: + return False + if month > 12: + return False + return True + +def rangeCheck(number, lower, upper): + if number > upper or number < lower: + return False + return True + +def dateCheck(date): + if len(date) != 10: + return False + if not(validNumber(date[0]) and validNumber(date[1]): + return False + if not(validNumber(date[3]) and validNumber(date[4]): + return False + if not(validNumber(date[6]) and validNumber(date[7]) and validNumber(date[8]) and validNumber(date[9]): + return False + return True + +if __name__ == "__main__": + firstName = input("Please type in your firstname: ") + number = input("please type a phone number: ") + year = input("what is the year: ") + + while not(validName(firstName)): + firstName = input("Please type in your firstname: ") + + while not(validNumber(number)): + number = input("Please type in a valid phone number: ") + + while not(validYear(year)): + year = input("Please type in a valid year: ") diff --git a/comp/work/13/find_smallest.py b/comp/work/13/find_smallest.py new file mode 100755 index 0000000..362383a --- /dev/null +++ b/comp/work/13/find_smallest.py @@ -0,0 +1,9 @@ +def find_smallest(numbers): + smallest = numbers[0] + for i in numbers: + if i < smallest: + smallest = i + return smallest + +numbers = [3, 6, 2, 8, 4, 1] +print(find_smallest(numbers)) diff --git a/comp/work/13/reverse_words.py b/comp/work/13/reverse_words.py new file mode 100755 index 0000000..974ae4d --- /dev/null +++ b/comp/work/13/reverse_words.py @@ -0,0 +1,6 @@ +def reverse_words(words): + words.split(" ") + output = [] + for i in words: + + diff --git a/comp/work/13/task.py b/comp/work/13/task.py new file mode 100755 index 0000000..ca7cd5e --- /dev/null +++ b/comp/work/13/task.py @@ -0,0 +1,14 @@ +def get_name(name): + return name.upper() + + +def get_age(current_age): + return current_age + 1 + +def get_details(name,age): + print(f"the persons name is {get_name(name)}, and next year they will be {get_age(age)}") + +name = input("name: ") +age = int(input("current age: ")) + +get_details(name,age) diff --git a/comp/work/2/fstring.py b/comp/work/2/fstring.py new file mode 100755 index 0000000..80d7d7c --- /dev/null +++ b/comp/work/2/fstring.py @@ -0,0 +1,4 @@ +red = "\e[1;35m" +normal = "\e[0;37m" + +print(f"{red}hello{normal}") diff --git a/comp/work/2/pi.py b/comp/work/2/pi.py new file mode 100755 index 0000000..93f216d --- /dev/null +++ b/comp/work/2/pi.py @@ -0,0 +1,2 @@ +import math +print(f"{math.pi:.48f}") diff --git a/comp/work/2/shops.py b/comp/work/2/shops.py new file mode 100755 index 0000000..57cff25 --- /dev/null +++ b/comp/work/2/shops.py @@ -0,0 +1,25 @@ +total = int(input("how much does it cost: ")) +totalPayed = int(input("how much did you get: ")) + +if totalPayed < total: + print(f"{totalPayed:.2f} is not enough to pay for {total:.2f}") + exit() + +totalChange = totalPayed - total +changeToGive = [] +while totalChange != 0: + if totalChange >= 10: + totalChange = totalChange - 10 + changeToGive.append(10) + elif totalChange >= 5: + totalChange = totalChange - 5 + changeToGive.append(5) + elif totalChange >= 2: + totalChange = totalChange - 2 + changeToGive.append(2) + elif totalChange >= 1: + totalChange = totalChange - 1 + changeToGive.append(1) + +print(f"you need to give the customer : {changeToGive}") + diff --git a/comp/work/2/syntaxError b/comp/work/2/syntaxError new file mode 100755 index 0000000..988177a --- /dev/null +++ b/comp/work/2/syntaxError @@ -0,0 +1,6 @@ +print = ("....") print("...") + ^ +heigth-Str = input("...") height = int(input("...")) + ^ +base-Str = input("...") base = int(input("...")) + ^ diff --git a/comp/work/3/isIn.c b/comp/work/3/isIn.c new file mode 100755 index 0000000..8254099 --- /dev/null +++ b/comp/work/3/isIn.c @@ -0,0 +1,19 @@ +#include +#include +#include + +int isIn(char str1[], char str2[]){ + int str1Length = strlen(str1); + int str2Length = strlen(str2); + + for (int i = 0; i < str1Length; i++){ + for (int j = 0; j < str2Length; i++){ + if (str1[i] == str2[j]){ + return 0; + } + } +} + +int main(){ + +} diff --git a/comp/work/3/isSquare.py b/comp/work/3/isSquare.py new file mode 100755 index 0000000..5dea990 --- /dev/null +++ b/comp/work/3/isSquare.py @@ -0,0 +1,5 @@ +base = int(input("height: ")) +height = int(input("base: ")) + +if base == height: + print("its a square") diff --git a/comp/work/3/password.py b/comp/work/3/password.py new file mode 100755 index 0000000..7a592d8 --- /dev/null +++ b/comp/work/3/password.py @@ -0,0 +1,6 @@ +password = "beans" + +if input("password: ") == password: + print("welcome back beany bob") +else: + print("password was wrong") diff --git a/comp/work/3/year.py b/comp/work/3/year.py new file mode 100755 index 0000000..854c2c5 --- /dev/null +++ b/comp/work/3/year.py @@ -0,0 +1,4 @@ +year = int(input("whats the year? ")) + +if (year % 4) == 0: + print("its a leep year") diff --git a/comp/work/4/pythagorus b/comp/work/4/pythagorus new file mode 100755 index 0000000..d9c5cdc --- /dev/null +++ b/comp/work/4/pythagorus @@ -0,0 +1,6 @@ +#!/usr/bin/python +base = float(input("base: ")) +height = float(input("height: ")) + +hyp = ((base ** 2) + (height ** 2)) ** 0.5 +print(hyp) diff --git a/comp/work/4/sumAndMean b/comp/work/4/sumAndMean new file mode 100755 index 0000000..1d46136 --- /dev/null +++ b/comp/work/4/sumAndMean @@ -0,0 +1,6 @@ +#!/usr/bin/python3 +numbers = [] +for i in range(5): + numbers.append(int(input(f"num {i}: "))) +print(f"sum = {float(sum(numbers))}") +print(f"average = {(sum(numbers) / 5)}") diff --git a/comp/work/5/567.py b/comp/work/5/567.py new file mode 100755 index 0000000..691d278 --- /dev/null +++ b/comp/work/5/567.py @@ -0,0 +1,10 @@ +import sys + +for x in range(1,11): + for i in range(x, (x*10)+1): + if i % x == 0: + if i >= 10: + sys.stdout.write(str(i)+" ") + else: + sys.stdout.write(str(i)+" ") + print("") diff --git a/comp/work/5/name.py b/comp/work/5/name.py new file mode 100755 index 0000000..b822ae8 --- /dev/null +++ b/comp/work/5/name.py @@ -0,0 +1,5 @@ +name = input("name: ") +counter = len(name) +for i in name: + print(f"{name:.{counter}}") + counter = counter - 1 diff --git a/comp/work/5/odd.py b/comp/work/5/odd.py new file mode 100755 index 0000000..7fde107 --- /dev/null +++ b/comp/work/5/odd.py @@ -0,0 +1,3 @@ +for i in range(40): + if i % 2 != 0: + print(i) diff --git a/comp/work/5/printCon b/comp/work/5/printCon new file mode 100755 index 0000000..da5a756 --- /dev/null +++ b/comp/work/5/printCon @@ -0,0 +1,5 @@ +word = "computing" +for i in word: + if i != 'a' and i != 'e' and i != 'i' and i != 'o' and i != 'u': + print(i) + diff --git a/comp/work/5/wordCount.py b/comp/work/5/wordCount.py new file mode 100755 index 0000000..8674b3f --- /dev/null +++ b/comp/work/5/wordCount.py @@ -0,0 +1,12 @@ +sentence = input("sentence: ") + +cons = 0 +spaces = 0 + +for i in sentence: + if i == ' ': + spaces =+ 1 + + if i != 'a' and i != 'e' and i != 'i' and i != 'o' and i != 'u': + cons = cons + 1 +print("there are", cons - 2, "consinants and", spaces + 2, "words") diff --git a/comp/work/5/xTo.py b/comp/work/5/xTo.py new file mode 100755 index 0000000..84c67bb --- /dev/null +++ b/comp/work/5/xTo.py @@ -0,0 +1,2 @@ +for i in range(21): + print(i, i**2, i**3) diff --git a/comp/work/6/5timesTable.py b/comp/work/6/5timesTable.py new file mode 100755 index 0000000..e7be413 --- /dev/null +++ b/comp/work/6/5timesTable.py @@ -0,0 +1,8 @@ +num = int(input("number: ")) + +if num < 0: + exit(1) + +for i in range(num+1): + if (i % 5) == 0: + print(i) diff --git a/comp/work/6/cake.py b/comp/work/6/cake.py new file mode 100755 index 0000000..23f4e44 --- /dev/null +++ b/comp/work/6/cake.py @@ -0,0 +1,8 @@ +while True: + eggs = int(input("how many eggs are there: ")) + if eggs < 8: + break +flour = eggs * 100 +sugar = eggs * 50 + +print("you will need", flour, "grams and", sugar, "grams") diff --git a/comp/work/6/iceCream.py b/comp/work/6/iceCream.py new file mode 100755 index 0000000..10db61c --- /dev/null +++ b/comp/work/6/iceCream.py @@ -0,0 +1,29 @@ +while True: + week = input("is it a week day: (yes/no) ").lower() + if week == "yes": + break + elif week == "no": + break + +while True: + temp = int(input("what is the temprature: ")) + if temp >= 20: + if temp <= 45: + break +sold = 0 +if week == "no": + if 20 <= temp <= 30: + sold = 200 + elif 31 <= temp <= 38: + sold = 300 + else: + sold = 240 +elif week == "yes": + if 20 <= temp <= 30: + sold = 200/2 + elif 31 <= temp <= 38: + sold = 300/2 + else: + sold = 240/2 +print(sold, "ice creams will be sold") + diff --git a/comp/work/7/dice.py b/comp/work/7/dice.py new file mode 100755 index 0000000..83ec09c --- /dev/null +++ b/comp/work/7/dice.py @@ -0,0 +1,26 @@ +import random + +dice = [] +for i in range(200): + dice.append(random.randint(1, 6)) + +count = [] +for i in range(6): + count.append(0) +for i in dice: + if i == 1: + count[0] = count[0] + 1 + elif i == 2: + count[1] = count[1] + 1 + elif i == 3: + count[2] = count[2] + 1 + elif i == 4: + count[3] = count[3] + 1 + elif i == 5: + count[4] = count[4] + 1 + else: + count[5] = count[5] + 1 + +for i in range(len(count)): + print("there are", count[i], str(i)+"'s") + diff --git a/comp/work/7/famous.py b/comp/work/7/famous.py new file mode 100755 index 0000000..7da792f --- /dev/null +++ b/comp/work/7/famous.py @@ -0,0 +1,26 @@ +name = ["tux", "wibler", "rms"] +clue1 = ["its a penguin", "it likes art", "what your refering to..."] +clue2 = ["it could have been a furry", "its a dog", "...as linux, is accutally gnu/linux"] + +score = 0 + +for x in range(3): + print(clue1[x]) + guess = input("who do you think it is? ") + if guess == name[x]: + print("you got it!") + score = score + 5 + else: + print(clue2[x]) + guess = input("who do you think it is now? ") + if guess == name[x]: + print("well done, you got it that time!") + score = score + 2 + else: + print("sorry that was wrong") + print("it was,", name[x]) + print("\n\n\n") + +print("you got,", score, "points") + + diff --git a/comp/work/7/friends.py b/comp/work/7/friends.py new file mode 100755 index 0000000..5d23111 --- /dev/null +++ b/comp/work/7/friends.py @@ -0,0 +1,7 @@ +friends = ["john", "ben", "sam", "micky mouse", "donald duck"] + +print(*friends, sep='\n') +friends.reverse() +print("\n\n\n") +print(*friends, sep='\n') + diff --git a/comp/work/7/input.py b/comp/work/7/input.py new file mode 100755 index 0000000..a9e5c8f --- /dev/null +++ b/comp/work/7/input.py @@ -0,0 +1,18 @@ +numbers = [] +for i in range(10): + numbers.append(int(input("number: "))) +total = sum(numbers) +mean = total / len(numbers) + +print("total =",total, "mean =",mean) + +above = 0 +for i in numbers: + if i < mean: + print(i, "is less than average (HA SMOL)") + elif i == mean: + print(i, "is average (BORINGGG)") + else: + print(i, "is more than average (DAMMNNNN)") + above = above + 1 +print(above, "numbers are above average") diff --git a/comp/work/8/ascii b/comp/work/8/ascii new file mode 100755 index 0000000..8260b96 Binary files /dev/null and b/comp/work/8/ascii differ diff --git a/comp/work/8/ascii.c b/comp/work/8/ascii.c new file mode 100755 index 0000000..751c1b9 --- /dev/null +++ b/comp/work/8/ascii.c @@ -0,0 +1,7 @@ +#include + +int main(){ + int c; + scanf("%c", &c); + printf("%d\n", c); +} diff --git a/comp/work/8/ascii_word b/comp/work/8/ascii_word new file mode 100755 index 0000000..3ede671 Binary files /dev/null and b/comp/work/8/ascii_word differ diff --git a/comp/work/8/ascii_word.c b/comp/work/8/ascii_word.c new file mode 100755 index 0000000..ba9fa95 --- /dev/null +++ b/comp/work/8/ascii_word.c @@ -0,0 +1,11 @@ +#include +#include +int main(){ + char sentence[1000]; + + fgets(sentence, 1000, stdin); + for (int i = 0; i < strlen(sentence) - 1; i++){ + printf("%d \0 ", (int)sentence[i]); + } + printf("\n"); +} diff --git a/comp/work/8/parity b/comp/work/8/parity new file mode 100755 index 0000000..66738ce Binary files /dev/null and b/comp/work/8/parity differ diff --git a/comp/work/8/parity.c b/comp/work/8/parity.c new file mode 100755 index 0000000..a87d07a --- /dev/null +++ b/comp/work/8/parity.c @@ -0,0 +1,34 @@ +#include +#include +#include + +int main(){ + char num[8]; + int parity; + scanf("%s", num); + char number[8]; + for (int i = 0; i < 8; i++){ + if (i == 7){ + if (num[i] == '1'){ + parity = 1; + }else{ + parity = 0; + } + }else{ + if (num[i] == '1'){ + number[i] = 1; + }else{ + number[i] = 0; + } + } + } + int number_of_ones = 0; + for (int i = 0; i < 8; i++){ + if (number[i] == 1){ + number_of_ones++; + } + } + if (number_of_ones % 2 == parity){ + printf("bad\n"); + } +} diff --git a/comp/work/9/scores.py b/comp/work/9/scores.py new file mode 100755 index 0000000..8abad3b --- /dev/null +++ b/comp/work/9/scores.py @@ -0,0 +1,21 @@ +scores = [[]] +for i in range(3): + tmp = [] + for j in range(5): + tmp.append(int(input(f"num {j}: "))) + scores.append(tmp) + +scores.pop(0) +for i in scores: + print(*i, "avg: ",(sum(i)/5), sep=" ") + +highest = scores[0][0] +lowest = scores[0][0] +for i in scores: + for j in i: + if j > highest: + highest = j + elif j < lowest: + lowest = j +print(f"highest: {highest}, lowest: {lowest}") + diff --git a/comp/work/9/tanks.py b/comp/work/9/tanks.py new file mode 100755 index 0000000..6584263 --- /dev/null +++ b/comp/work/9/tanks.py @@ -0,0 +1,10 @@ +board1 = [["."] * 10] * 10 +board2 = [["."] * 10] * 10 + +for i in board1: + print(*i, sep=" ") +for i in range(3): + board1[int(input("tank y: "))][int(input("tank x: "))] = "T" +for i in board1: + print(*i, sep=" ") + -- cgit v1.2.3