Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Seminar 4/from-class/problem1.md
Original file line number Diff line number Diff line change
@@ -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
```
4 changes: 2 additions & 2 deletions Seminar 4/from-class/problem1.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -8,4 +8,4 @@
names_counter[name] = 1

for name in names_counter:
print(name, ' ', names_counter[name])
print(name, '-', names_counter[name])
16 changes: 16 additions & 0 deletions Seminar 4/homework/problem1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Count strings in a list

Improve the <i>problem1 from class</i> by making the program string traverser case insensitive <i>(This means UPPER CASE and lower case are treated the same)</i>.

---
Sample list:
``` python
["IVAN", "Petkan", "Gosho", "petkan", "ivan", "Stamat", "Ivan", "petkAN", "ivan"]
```
Sample output:
```
ivan - 4
petkan - 3
gosho - 1
stamat - 1
```
42 changes: 42 additions & 0 deletions Seminar 4/homework/problem2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Count strings in a list

Improve the <i>problem1 from class</i> 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
```
25 changes: 25 additions & 0 deletions Seminar 4/homework/problem3.md
Original file line number Diff line number Diff line change
@@ -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: <i>.,!?;'"</i>

---
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
```