This repository has been archived by the owner on Jul 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
isj_proj02_xcaber00.py
78 lines (61 loc) · 1.97 KB
/
isj_proj02_xcaber00.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
import collections
# for task 1, 2, 3
eskymo = ['do', 'pre', 'du', 'du', 'do', 'za', 'du', 'du']
def first_task():
# number of all distinct strings in the eskymo list
vocabulary_size_eskymo = len(set(eskymo))
# test
return vocabulary_size_eskymo == 4
def second_task():
# for the next test
prepos = ['do', 'za', 'pred']
# all distinct strings in both the lists
in_both_eskymo_prepos = set(prepos).intersection(eskymo)
# test
in_both_str = ';'.join(in_both_eskymo_prepos)
return in_both_str == 'do;za' or in_both_str == 'za;do'
def third_task():
# what strings and how many times appeared in the eskymo list
wordfreq_eskymo = collections.Counter(eskymo)
# test
return ''.join(word + str(freq) for (word, freq) in wordfreq_eskymo.items()) == 'do2pre1du4za1'
def fourth_task():
# for the next test
udubutubudu = 'u dubu tu budu.'
# the udubutubudu string without the last character, backwards
backward_except_last = udubutubudu[:-1][::-1]
# test
return backward_except_last == 'udub ut ubud u'
def fifth_task():
# for the next test
hymn_st_john = 'Hymn of St. John: Ut queant laxis re sonare fibris mi ra gestorum fa muli tuorum sol ve polluti ' \
'la bii reatum SI Sancte Iohannes'
# the hymn as a list of strings separated by ' '
hymn_list = hymn_st_john.split(' ')
# the list starting from the fifth string, skipping always two strings
skip2 = hymn_list[4::3]
# the skip2 list as a string, ', ' as a separator
skip2_str = ', '.join(skip2)
# test
return skip2_str == 'Ut, re, mi, fa, sol, la, SI'
if first_task():
print('funguje')
else:
print('nefunguje')
if second_task():
print('funguje')
else:
print('nefunguje')
if third_task():
print('funguje')
else:
print('nefunguje')
if fourth_task():
print('funguje')
else:
print('nefunguje')
if fifth_task():
print('funguje')
else:
print('nefunguje')