From 8bc5978a99081cb215ff1b9a3451fa866b8cd570 Mon Sep 17 00:00:00 2001 From: Deyan Peev Date: Mon, 7 Nov 2022 09:38:58 +0200 Subject: [PATCH 01/13] Typos in text --- Seminar 3/from-class/problem2.md | 2 +- Seminar 3/from-class/problem3.md | 2 +- Seminar 3/from-class/problem4.md | 2 +- Seminar 3/from-class/problem5.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Seminar 3/from-class/problem2.md b/Seminar 3/from-class/problem2.md index be97995..a867998 100644 --- a/Seminar 3/from-class/problem2.md +++ b/Seminar 3/from-class/problem2.md @@ -1,6 +1,6 @@ # Letters contained in a string -Given a list of letters and a string, check if all the list's elements are contained in the string +Given a list of letters and a string, check if all the list's elements are contained in the string. --- Sample input: diff --git a/Seminar 3/from-class/problem3.md b/Seminar 3/from-class/problem3.md index 3b90c8a..368c0c7 100644 --- a/Seminar 3/from-class/problem3.md +++ b/Seminar 3/from-class/problem3.md @@ -1,6 +1,6 @@ # Draw a right-angled triangle -Given an integer number, print a right-angled triangle using the char * with as many lines as the given integer +Given an integer number, print a right-angled triangle using the char * with as many lines as the given integer. --- Sample input: diff --git a/Seminar 3/from-class/problem4.md b/Seminar 3/from-class/problem4.md index 82d5e2e..8a982c6 100644 --- a/Seminar 3/from-class/problem4.md +++ b/Seminar 3/from-class/problem4.md @@ -1,6 +1,6 @@ # Draw an oposite right-angled triangle -Given an integer number, print a right-angled triangle on the opposite side using the char * with as many lines as the given integer +Given an integer number, print a right-angled triangle on the opposite side using the char * with as many lines as the given integer. --- Sample input: diff --git a/Seminar 3/from-class/problem5.md b/Seminar 3/from-class/problem5.md index 2e2ea6f..91ae3ad 100644 --- a/Seminar 3/from-class/problem5.md +++ b/Seminar 3/from-class/problem5.md @@ -1,6 +1,6 @@ # Draw a pyramid -Given an integer number, print a pyramid using the char * with as many lines as the given integer +Given an integer number, print a pyramid using the char * with as many lines as the given integer. --- Sample input: From b2f13674fc718e17dd2fc8fa7b6a11366be7be53 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 12 Nov 2022 18:47:01 +0200 Subject: [PATCH 02/13] Problem from class --- Seminar 4/from-class/problem1.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Seminar 4/from-class/problem1.md diff --git a/Seminar 4/from-class/problem1.md b/Seminar 4/from-class/problem1.md new file mode 100644 index 0000000..e69de29 From 9f4e2971ab545db87e337978317fda48a4e1bac1 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 12 Nov 2022 18:56:03 +0200 Subject: [PATCH 03/13] Problem from class --- Seminar 4/from-class/problem1.md | 16 ++++++++++++++++ Seminar 4/from-class/problem1.py | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Seminar 4/from-class/problem1.md b/Seminar 4/from-class/problem1.md index e69de29..1cce133 100644 --- a/Seminar 4/from-class/problem1.md +++ b/Seminar 4/from-class/problem1.md @@ -0,0 +1,16 @@ +# Count strings in a list + +Given a string list, print each string and how many times is the string contained. The list string is preset in the program and not passed as input. + +--- +Sample list: +``` python +["ivan", "petkan", "gosho", "petkan", "ivan", "stamat", "ivan", "petkan", "ivan"] +``` +Sample output: +``` +ivan - 4 +petkan - 3 +gosho - 1 +stamat - 1 +``` \ No newline at end of file diff --git a/Seminar 4/from-class/problem1.py b/Seminar 4/from-class/problem1.py index 3c786e5..417086b 100644 --- a/Seminar 4/from-class/problem1.py +++ b/Seminar 4/from-class/problem1.py @@ -1,4 +1,4 @@ -names = ['ivan', 'petkan', 'stamat', 'ivan', 'pencho', 'pencho', 'ivan'] +names = ["ivan", "petkan", "gosho", "petkan", "ivan", "stamat", "ivan", "petkan", "ivan"] names_counter = dict() for name in names: @@ -8,4 +8,4 @@ names_counter[name] = 1 for name in names_counter: - print(name, ' ', names_counter[name]) \ No newline at end of file + print(name, '-', names_counter[name]) \ No newline at end of file From 8359c972e3d19386dbe6754b981262b543417e30 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 12 Nov 2022 19:02:51 +0200 Subject: [PATCH 04/13] homework problem 1 --- Seminar 4/homework/problem1.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Seminar 4/homework/problem1.md diff --git a/Seminar 4/homework/problem1.md b/Seminar 4/homework/problem1.md new file mode 100644 index 0000000..dfd1f0a --- /dev/null +++ b/Seminar 4/homework/problem1.md @@ -0,0 +1,16 @@ +# Count strings in a list + +Improve the problem1 from class by making the program string traverser case insensitive (This means UPPER CASE and lower case are treated the same). + +--- +Sample list: +``` python +["IVAN", "Petkan", "Gosho", "petkan", "ivan", "Stamat", "Ivan", "petkAN", "ivan"] +``` +Sample output: +``` +ivan - 4 +petkan - 3 +gosho - 1 +stamat - 1 +``` \ No newline at end of file From 35798593b8037f6655e309988b102669cc599412 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 12 Nov 2022 19:03:17 +0200 Subject: [PATCH 05/13] homework problem 2 --- Seminar 4/homework/problem2.md | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Seminar 4/homework/problem2.md diff --git a/Seminar 4/homework/problem2.md b/Seminar 4/homework/problem2.md new file mode 100644 index 0000000..a7ae0df --- /dev/null +++ b/Seminar 4/homework/problem2.md @@ -0,0 +1,42 @@ +# Count strings in a list + +Improve the problem1 from class by reading the list from the console. + +The first thing the program should ask is the length of the string list - N. The next N inputs will be strings and will be appended to the original list. + +The rest of the program will behave the same. + +--- +Sample input: +``` python +4 +Ivan +Gosho +Ivan +Stamat +``` +Sample output: +``` +ivan - 2 +gosho - 1 +stamat - 1 +``` +--- +Sample input: +``` python +7 +book +cook +look +cook +look +cook +rook +``` +Sample output: +``` +book - 1 +cook - 3 +look - 2 +rook - 1 +``` \ No newline at end of file From f1a160591953cb85714599de47aa13b094a992fb Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 12 Nov 2022 19:24:23 +0200 Subject: [PATCH 06/13] Problem 3 homework --- Seminar 4/homework/problem3.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Seminar 4/homework/problem3.md diff --git a/Seminar 4/homework/problem3.md b/Seminar 4/homework/problem3.md new file mode 100644 index 0000000..1b23fb1 --- /dev/null +++ b/Seminar 4/homework/problem3.md @@ -0,0 +1,25 @@ +# Count the words in a sentence + +Given a string sentatnce, split it to words and count how many times each word is contained. + +The program should be case insensitive. + +Splitting/ignored characters: .,!?;'" + +--- +Sample input: +``` python +A big black bug bit a big black dog on his big black nose +``` +Sample output: +``` +a - 2 +big - 3 +black - 3 +bug - 1 +bit - 1 +dog - 1 +on - 1 +his - 1 +nose - 1 +``` From f130d70a5b1beb6f7c6d801a73e923cbe246ee3a Mon Sep 17 00:00:00 2001 From: deyanpeev Date: Sat, 12 Nov 2022 19:49:26 +0200 Subject: [PATCH 07/13] problem 4 homework 4 --- Seminar 4/homework/problem4.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Seminar 4/homework/problem4.md diff --git a/Seminar 4/homework/problem4.md b/Seminar 4/homework/problem4.md new file mode 100644 index 0000000..c19ad3c --- /dev/null +++ b/Seminar 4/homework/problem4.md @@ -0,0 +1,24 @@ +# Find common elements + +Given a list of lists, print the common elements in all lists + +The list string is preset in the program and not passed as input. + +--- +Sample input: +``` python +[[2, 17, 3, 4, 17], [2, 3, 1, 2], [82, 2, 4, 3, 20, 60 , 4, 4]] +``` +Sample output: +``` +2, 3 +``` +--- +Sample input: +``` python +[['a', 'b', 'c'], ['b', 'c', 'd'], ['c', 'd', 'e']] +``` +Sample output: +``` +c +``` \ No newline at end of file From 8f8ea89b9223598012f71a72ebd6a0e830473318 Mon Sep 17 00:00:00 2001 From: Deyan Peev Date: Thu, 17 Nov 2022 22:00:58 +0200 Subject: [PATCH 08/13] [Seminar 3] Homework problem 1 solved --- Seminar 3/homework/problem1-solved.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Seminar 3/homework/problem1-solved.py diff --git a/Seminar 3/homework/problem1-solved.py b/Seminar 3/homework/problem1-solved.py new file mode 100644 index 0000000..51d2242 --- /dev/null +++ b/Seminar 3/homework/problem1-solved.py @@ -0,0 +1,13 @@ +LETTERS_TO_EXCLUDE = ['a', 'e', 'i', 'o', 'u'] + +words = ["vowel", "consonant"] +new_words = [] + +for word in words: + new_word = [] # the word will be array of characters wich will later be joined in a string + for letter in word: + if letter.casefold() not in LETTERS_TO_EXCLUDE: + new_word.append(letter) + new_words.append("".join(new_word)) + +print(new_words) From a95ae5545506aae3d41fc84cc58a2a4586c6d1af Mon Sep 17 00:00:00 2001 From: Deyan Peev Date: Fri, 18 Nov 2022 23:08:54 +0200 Subject: [PATCH 09/13] Problem 2 solved --- Seminar 3/homework/problem2-solved.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Seminar 3/homework/problem2-solved.py diff --git a/Seminar 3/homework/problem2-solved.py b/Seminar 3/homework/problem2-solved.py new file mode 100644 index 0000000..b10bea1 --- /dev/null +++ b/Seminar 3/homework/problem2-solved.py @@ -0,0 +1,16 @@ +from math import ceil, floor + +EMPTY_SPACE = ' ' +CHAR_TO_REPEAT = '*' + +lines_number = int(input("Enter a number: ")) +lines_number /= 2 +line = 0 +while line < lines_number: + print(EMPTY_SPACE * (ceil(lines_number) - line - 1) + CHAR_TO_REPEAT * (line * 2 + 1)) + line+=1 + +lines_number -= 1 +while lines_number >= 0: + print(EMPTY_SPACE * (line - floor(lines_number) - 1) + CHAR_TO_REPEAT * (floor(lines_number) * 2 + 1)) + lines_number-=1 \ No newline at end of file From ab247cbd171747dca82d2949479b884e17835f83 Mon Sep 17 00:00:00 2001 From: Deyan Peev Date: Fri, 18 Nov 2022 23:18:48 +0200 Subject: [PATCH 10/13] Problem 3 solved --- Seminar 3/homework/problem3-solved.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Seminar 3/homework/problem3-solved.py diff --git a/Seminar 3/homework/problem3-solved.py b/Seminar 3/homework/problem3-solved.py new file mode 100644 index 0000000..954c411 --- /dev/null +++ b/Seminar 3/homework/problem3-solved.py @@ -0,0 +1,10 @@ +EMPTY_SPACE = ' ' +CHAR_TO_REPEAT = '*' + +lines_number = int(input("Enter a number: ")) +line = 0 +while line < lines_number - 1: + print(EMPTY_SPACE * (lines_number - line - 1) + CHAR_TO_REPEAT * (line * 2 + 1)) + line+=1 + +print(EMPTY_SPACE * (lines_number - 1) + CHAR_TO_REPEAT) \ No newline at end of file From 1d76ed6daad6c50085a4014643dee71288751a24 Mon Sep 17 00:00:00 2001 From: deyanpeev Date: Wed, 14 Dec 2022 18:50:49 +0200 Subject: [PATCH 11/13] Task definition --- Seminar 7/task.md5 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Seminar 7/task.md5 diff --git a/Seminar 7/task.md5 b/Seminar 7/task.md5 new file mode 100644 index 0000000..32aff50 --- /dev/null +++ b/Seminar 7/task.md5 @@ -0,0 +1,37 @@ +# Computer mini program + +Create a mini program that works with the following class definitions: +## Computer +### Attributes +* cpu - number value +* memory - number value +* storage - number value + +### Methods +Create constructor and override the __str__ method to print all the parameters listed. + +## Laptop +Should inherit the computer and add the following: +### Attributes +* gpu - number value +### Methods +* play_game - if gpu is greater than 2 - print "Playing a game". Otherwise, print "Unable to perform operation." +* design - if gpu is greater than 1 - print "Designing". Otherwise, print "Unable to perform operation." + +The memory of the laptop should be able to be changed - create a property for it. + +## Smartphone +Should inherit the computer and add the following: +### Attributes +* cellular - string value +* phone_number - string value +### Methods +* make_phone_call - the method should take a parameter caller and print "{phone_number} is calling {to_number}" +* receive_phone_call - the method should print "{phone_number} is receiving a call" + +## GamingLaptop +In the inicialization of this class it should set the GPU value to 5. +### Methods +* play_extreme_game - just print "Playing an extreme game". + +Each values should be set in the constructors. The constructor of each child class should reuse its parant's. \ No newline at end of file From 179d71f6adee8e63e46a27519e161b55c76f1e78 Mon Sep 17 00:00:00 2001 From: deyanpeev Date: Wed, 14 Dec 2022 19:01:00 +0200 Subject: [PATCH 12/13] Solution --- Seminar 7/problem-in-class/Computer.py | 16 +++++++++++++ Seminar 7/problem-in-class/GamingLaptop.py | 8 +++++++ Seminar 7/problem-in-class/Laptop.py | 27 ++++++++++++++++++++++ Seminar 7/problem-in-class/Smartphone.py | 18 +++++++++++++++ Seminar 7/problem-in-class/main.py | 18 +++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 Seminar 7/problem-in-class/Computer.py create mode 100644 Seminar 7/problem-in-class/GamingLaptop.py create mode 100644 Seminar 7/problem-in-class/Laptop.py create mode 100644 Seminar 7/problem-in-class/Smartphone.py create mode 100644 Seminar 7/problem-in-class/main.py diff --git a/Seminar 7/problem-in-class/Computer.py b/Seminar 7/problem-in-class/Computer.py new file mode 100644 index 0000000..1895f13 --- /dev/null +++ b/Seminar 7/problem-in-class/Computer.py @@ -0,0 +1,16 @@ +class Computer: + def __init__(self, cpu, memory, storage): + self.__cpu = cpu + self.__memory = memory + self.__storage = storage + + @property + def _memory(self): + return self.__memory + + @_memory.setter + def _memory(self, value): + self.__memory = value + + def __str__(self) -> str: + return f"CPUs: {self.__cpu}; Memory: {self.__memory}; Storage: {self.__storage}; " diff --git a/Seminar 7/problem-in-class/GamingLaptop.py b/Seminar 7/problem-in-class/GamingLaptop.py new file mode 100644 index 0000000..f73d95c --- /dev/null +++ b/Seminar 7/problem-in-class/GamingLaptop.py @@ -0,0 +1,8 @@ +from Laptop import Laptop + +class GamingLaptop(Laptop): + def __init__(self, cpu, memory, storage): + Laptop.__init__(self, cpu, memory, storage, 5) + + def playExtremeGames(): + print("Playing some super cool games.") \ No newline at end of file diff --git a/Seminar 7/problem-in-class/Laptop.py b/Seminar 7/problem-in-class/Laptop.py new file mode 100644 index 0000000..b2e8e53 --- /dev/null +++ b/Seminar 7/problem-in-class/Laptop.py @@ -0,0 +1,27 @@ +from Computer import Computer + +class Laptop(Computer): + pass + def __init__(self, cpu, memory, storage, gpu): + Computer.__init__(self, cpu, memory, storage) + self.__gpu = gpu + + @property + def memory(self): + return self._memory + + @memory.setter + def memory(self, value): + self._memory = value + + def startPlayingGames(self, game): + if(self.__gpu < 2): + print("You can't play games on this laptop.") + else: + print(f"Playing {game}") + + def startDesigning(self): + if(self.__gpu < 1): + print("You can't use this laptop for design.") + else: + print("Designing") \ No newline at end of file diff --git a/Seminar 7/problem-in-class/Smartphone.py b/Seminar 7/problem-in-class/Smartphone.py new file mode 100644 index 0000000..2f009ed --- /dev/null +++ b/Seminar 7/problem-in-class/Smartphone.py @@ -0,0 +1,18 @@ +from Computer import Computer + +class Smartphone(Computer): + pass + def __init__(self, cpu, memory, storage, cellular, phoneNumber): + Computer.__init__(self, cpu, memory, storage) + self.__cellular = cellular + self.__phoneNumber = phoneNumber + + + def receivePhoneCall(self): + print(f"{self.__phoneNumber} is receiving a call.") + + def makePhoneCall(self, to_number): + print(f"{self.__phoneNumber} will call {to_number}") + + def __str__(self) -> str: + return super().__str__() + f"Cellular: {self.__cellular}; Phone number: {self.__phoneNumber}" \ No newline at end of file diff --git a/Seminar 7/problem-in-class/main.py b/Seminar 7/problem-in-class/main.py new file mode 100644 index 0000000..3502919 --- /dev/null +++ b/Seminar 7/problem-in-class/main.py @@ -0,0 +1,18 @@ +from Laptop import Laptop +from Smartphone import Smartphone +from GamingLaptop import GamingLaptop + +def main(): + print('starting main') + bad_laptop = Laptop(2.4, 16, 512, 0.1) + glaptop = GamingLaptop(4, 16, 1024) + sp = Smartphone(1, 2, 8, 'A1', '0883') + + bad_laptop.startPlayingGames('CS') + glaptop.startPlayingGames('CS') + sp.makePhoneCall("testing") + + print(bad_laptop) + +if __name__ == "__main__": + main() \ No newline at end of file From 51a92c3ab37189f2532e58db3a3f074875e382bd Mon Sep 17 00:00:00 2001 From: Deyan Peev Date: Thu, 15 Dec 2022 18:36:09 +0200 Subject: [PATCH 13/13] mini fix --- {Seminar5 => Seminar 5}/from-class/problem1.py | 0 {Seminar5 => Seminar 5}/from-class/problem2.py | 0 {Seminar5 => Seminar 5}/from-class/problem3.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {Seminar5 => Seminar 5}/from-class/problem1.py (100%) rename {Seminar5 => Seminar 5}/from-class/problem2.py (100%) rename {Seminar5 => Seminar 5}/from-class/problem3.py (100%) diff --git a/Seminar5/from-class/problem1.py b/Seminar 5/from-class/problem1.py similarity index 100% rename from Seminar5/from-class/problem1.py rename to Seminar 5/from-class/problem1.py diff --git a/Seminar5/from-class/problem2.py b/Seminar 5/from-class/problem2.py similarity index 100% rename from Seminar5/from-class/problem2.py rename to Seminar 5/from-class/problem2.py diff --git a/Seminar5/from-class/problem3.py b/Seminar 5/from-class/problem3.py similarity index 100% rename from Seminar5/from-class/problem3.py rename to Seminar 5/from-class/problem3.py