Last active 1764707069

stopwords.py Raw
1def countwords(lst):
2 word_count = {}
3
4 for word in lst:
5 if word in word_count:
6 word_count[word] += 1
7 else:
8 word_count[word] = 1
9 return word_count
10
11def wordsOfLength(w, n):
12 result = []
13 for word, count in w.items():
14 if count >= n:
15 result.append(word)
16 return result
17
18def stopWords(text, k):
19 l = text.split()
20 w = countwords(l)
21 results = wordsOfLength(w, k)
22 return results
23
24
sumdisc.py Raw
1
2def shopping_total(n, items):
3 #print("f", n, items)
4 tot = 0.0
5 disc = lambda price: price * 0.9 if price > 50 else price
6 for a, price in items:
7 tot = tot + disc(price)
8 return round(tot, 1)
9