-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathulohy_2.py
105 lines (91 loc) · 2.63 KB
/
ulohy_2.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import re
import sys
import time
from random import randint
from itertools import permutations
def ask():
x = str(input("\n1) Pankrac\n2) Tajna sprava\n3) Sedi mucha na stene\n4) Alergia\n5) Rigorozka\n6) Statisticky urad\nPre ukoncenie stlacte ENTER\n>"))
if x == "1":
pankrac()
elif x == "2":
tajna()
elif x == "3":
mucha()
elif x == "4":
alergia()
elif x == "5":
rigorozka()
elif x == "6":
statistika()
elif x == "":
sys.exit()
else:
print(x,"is not a valid character, please try again")
ask()
def pankrac():
y = str(input("Veta?\n>")).split(" ")
ls = []
ls1 = []
nn = 0
for i in range(0, len(y)):
if y[i].istitle() == True: ls.append(y[i].swapcase())
elif y[i].isupper() == True:
sp = list(y[i])
for n in sp:
if nn == 0:
ls1.append(n.swapcase())
nn = nn + 1
else: ls1.append(n)
ls.append("".join(ls1))
else: ls.append(y[i])
print(" ".join(ls))
print(" ".join([word[0].lower()+word[1:].upper() if word[0].isupper() else word for word in input("Sentence?\n>>> ").split(" ")]))
time.sleep(1)
ask()
def tajna():
x = list(str(input("Veta?\n>")))
count = -1
popls = []
for i in x:
count = count + 1
if i == " ": popls.append(count)
plusindex = 0
for i in popls:
x.pop(i + plusindex)
plusindex = plusindex-1
append_num = len(popls)
for i in range(0,append_num): x.insert(randint(1,len(x)-1)," ")
print("".join(x))
time.sleep(1)
ask()
def mucha():
p = str(input("Pismeno?\n>"))
x = list(str(input("Veta?\n>")))
for i in x:
if i == "a" or i == "e" or i == "i" or i == "o" or i == "u": print(p, end = "")
elif i == "A" or i == "E" or i == "I" or i == "O" or i == "U": print(p.upper(), end = "")
else: print(i, end = "")
time.sleep(1)
ask()
def alergia():
a = list(str(input("Veta?\n>")))
for n in a:
if n.isalpha() == True or n == " ": print(n, end = "")
time.sleep(1)
ask()
def rigorozka():
x = permutations(str(input("Text?\n>")).split(" "))
for i in x: print(" ".join(i))
time.sleep(1)
ask()
def statistika():
text = str(input("Veta?\n>")).upper()
letters = {}
for i in re.findall(r"\w", text):
if i not in letters: letters[i] = 1
else: letters[i] += 1
SortedByCount = dict(sorted(letters.items(), key = lambda x: x[1], reverse = True))
print(" ".join(SortedByCount.keys()))
time.sleep(1)
ask()
ask()