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/hw/1/1.py | 4 ++ comp/hw/1/2.py | 7 +++ comp/hw/1/3.py | 10 +++++ comp/hw/1/4.py | 31 +++++++++++++ comp/notes/1 | 25 +++++++++++ comp/notes/2 | 20 +++++++++ comp/notes/3 | 5 +++ comp/notes/4 | 15 +++++++ comp/notes/5 | 18 ++++++++ comp/notes/6/archictecture | 21 +++++++++ comp/while/1.py | 10 +++++ comp/while/2.py | 13 ++++++ 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 +++++ 60 files changed, 693 insertions(+) create mode 100755 comp/hw/1/1.py create mode 100755 comp/hw/1/2.py create mode 100755 comp/hw/1/3.py create mode 100755 comp/hw/1/4.py create mode 100755 comp/notes/1 create mode 100755 comp/notes/2 create mode 100755 comp/notes/3 create mode 100755 comp/notes/4 create mode 100755 comp/notes/5 create mode 100755 comp/notes/6/archictecture create mode 100755 comp/while/1.py create mode 100755 comp/while/2.py 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') diff --git a/comp/hw/1/1.py b/comp/hw/1/1.py new file mode 100755 index 0000000..4eee13e --- /dev/null +++ b/comp/hw/1/1.py @@ -0,0 +1,4 @@ +num = int(input("number: ")) +for i in range(10,21): + if num == i: + print("is in range") diff --git a/comp/hw/1/2.py b/comp/hw/1/2.py new file mode 100755 index 0000000..dd1c619 --- /dev/null +++ b/comp/hw/1/2.py @@ -0,0 +1,7 @@ +age = int(input("age: ")) +if age >= 18: + print("user is an adult") +elif age < 13: + print("user is a child") +else: + print("user is a teenager") diff --git a/comp/hw/1/3.py b/comp/hw/1/3.py new file mode 100755 index 0000000..a84d7e2 --- /dev/null +++ b/comp/hw/1/3.py @@ -0,0 +1,10 @@ +import sys +num = [] +num.append(int(input("number: "))) +num.append(int(input("number: "))) +num.append(int(input("number: "))) + +num.sort() +for i in num: + sys.stdout.write(f"{i} ") +print("\n") diff --git a/comp/hw/1/4.py b/comp/hw/1/4.py new file mode 100755 index 0000000..fb28133 --- /dev/null +++ b/comp/hw/1/4.py @@ -0,0 +1,31 @@ +marks = [] +marks.append(int(input("analysis: "))) +marks.append(int(input("design: "))) +marks.append(int(input("implimentation: "))) +marks.append(int(input("evaluation: "))) + +total = 0 +for i in marks: + total = total + i + +if total >= 80: + print("9") +elif 80 > total >= 67: + print("8") +elif 67 < total <= 54: + print("7") +elif 54 < total <= 41: + print("6") +elif 41 < total <= 31: + print("5") +elif 31 < total <= 22: + print("4") +elif 22 < total <= 13: + print("3") +elif 13 < total <= 4: + print("2") +elif 4 < total <= 2: + print("1") +else: + print("U") +print("total ", total) diff --git a/comp/notes/1 b/comp/notes/1 new file mode 100755 index 0000000..3ce4743 --- /dev/null +++ b/comp/notes/1 @@ -0,0 +1,25 @@ +lesson 1 + +looking at binary +ordinal numbers - indexes, counters etc +natural numbers - start from 0 +intergers - just any number +rational numbers - just decimals + +should learn negative binary and floating point binary + +normal multiplication works in binary as well, its just multiplying by 1 or 0 + +we looked at binary addition and multiplication + +we looked at hex to denary + +gonna do some programming + + +todo: + floating point binary + negative binary + hex addition and multiplication +`done! + diff --git a/comp/notes/2 b/comp/notes/2 new file mode 100755 index 0000000..c0f686d --- /dev/null +++ b/comp/notes/2 @@ -0,0 +1,20 @@ +starting task +1) 103 +2) 10 10011011 +3) 10101001 x wrong numbers used +4) binary, denary, hexadecimal, octodecimal (base 8) x natural rational integer real + +from gcse remember spliting a binary number every 4 bits and convert to hex + +when you have signed bit it means - of the bit that is signed (usualy 128) + all the other values +your colums would be -128, 64, 32, 16, 8, 4, 2, 1 +if you have less bits it might look like this -8, 4, 2, 1 +same for if you have more bits + +we did some fixed point binary, it goes like this, -128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25.. +it is clear why we use floating point numbers + +THE EXAM THINKS THAT 1G = 1000KB +THEY CALL 1024KB = 1 Gibibyte + +2^n is the maximum amount of values, n = the number of bits diff --git a/comp/notes/3 b/comp/notes/3 new file mode 100755 index 0000000..b15a121 --- /dev/null +++ b/comp/notes/3 @@ -0,0 +1,5 @@ +the first half of the lesson was recapping floating point numbers +for a standard value there will always be 1 bit then the decimal point then the rest of the factional value +a standard value will have a ten bit fractional value and a 6 bit exponent (both will be signed) + +second half of the lesson is programming diff --git a/comp/notes/4 b/comp/notes/4 new file mode 100755 index 0000000..b263173 --- /dev/null +++ b/comp/notes/4 @@ -0,0 +1,15 @@ +the os is a tool designed to make the hardware easier to interactive with, it does this via masking the hardware into easier forms, look at /dev/wsmouse0 for an example + +it also needs to make programs easier to write and run, however doing this limits them to the platform they are compiled for + +an os may provide apis (/sys on linux) (/dev on openbsd) which allow talking to the hardware and sending signals much easier + +there will be a vaiety of different ways of interacting with the os, there is a gui (smelly gui), a tui (better gui), and a cli (the right one) + +the os also needs to deal with memory and cpu alication, which ensures the system isn't going to use 100% cpu for a split second while running ls + +a virtual machine (in the sense they want me to know), is a disk image, use doas dd if=/ of=/dev/usb0 to make one + +the os also manages stuff getting writen to the drives, this is via the file system, on linux it will be ext4, btrfs, etc and on windows it will be ntfs or fat 32/64 + +remember that translators and compilers come under this topic as they translate to os specific binary files (see man clang for more) diff --git a/comp/notes/5 b/comp/notes/5 new file mode 100755 index 0000000..497d1d2 --- /dev/null +++ b/comp/notes/5 @@ -0,0 +1,18 @@ +io devices +barcode reader + it shines a light, then more light reflects from the white than the black, then it uses that to read a string + white is 0, black is 1 + barcodes have a product number on the right and a manufacture number on the left + the right hand side codes are writen through a not gate (inversed) +qr codes + the same as a barcode but 2d +digital cameras + they look at how much light enters the lens then depending on its color and brightness it will output a different value + each pixel the camera outputs must have its own small light/color sensor +lazer printer + a negative static charge is put on paper + puts ink down thats atractive to the negative charge +rfid + it sends some radio waves out, then reads the radio waves sent back + some devices require active power, while other can get power from the incoming radio waves + diff --git a/comp/notes/6/archictecture b/comp/notes/6/archictecture new file mode 100755 index 0000000..c770983 --- /dev/null +++ b/comp/notes/6/archictecture @@ -0,0 +1,21 @@ +there are 3 busses, data, control, address +the data carrys data from the cpu +the address carrys mem addresses +the control bus is used to talk to devices about what data to send + +von nueman architecture has all the things (cpu mem io) on the same bus + +harvard architecture has all the things seperateated on different busses, including mem split into program and data + +moddern cpus have a mix of the 2 architectures + +the two each have there own advantges + +von nueman is simpler overall however it can have limiting speeds as all the busses are shared + +harvard is generally faster as it doesnt have to share any busses, however it can be harder to work with as the developer has to specify which but they are sending data too +also the extra wires can make costs higher, however this will only ever effect very large scale production + +speed is determined by things like clock speed, core count and bus width + +a faster cpu may be faster overall, however certan workflows benifit from more cores diff --git a/comp/while/1.py b/comp/while/1.py new file mode 100755 index 0000000..08a4e21 --- /dev/null +++ b/comp/while/1.py @@ -0,0 +1,10 @@ +num = 0 +highest = 0 +lowest = 0 +while num != -1: + num = int(input("num: ")) + if num > highest: + highest = num + if num < lowest: + lowest = num +print("the highest value was",highest,"and the lowest value was",lowest) diff --git a/comp/while/2.py b/comp/while/2.py new file mode 100755 index 0000000..7929862 --- /dev/null +++ b/comp/while/2.py @@ -0,0 +1,13 @@ +import random + +guess = -1 +ans = random.randint(1,100) + +while guess != ans: + guess = int(input("guess: ")) + if guess < ans: + print("higher") + elif guess > ans: + print("lower") + + 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