From b2f13674fc718e17dd2fc8fa7b6a11366be7be53 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 12 Nov 2022 18:47:01 +0200 Subject: [PATCH 1/5] 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 2/5] 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 3/5] 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 4/5] 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 5/5] 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 +```