diff --git a/Seminar 4/from-class/problem1.md b/Seminar 4/from-class/problem1.md new file mode 100644 index 0000000..1cce133 --- /dev/null +++ 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 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 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 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 +```