• API
• FAQ
• Tools
• Archive
SHARE
TWEET

Untitled

a guest Dec 6th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #przyklad: tomek kupil cinkowi rafalowi wilkowi za 21 zl
2. #t c r w 21
3. #cinek sobie i wilkowi za 13
4. #c c w 13
5. #podsumuj
6. #p
7.
8. def lettertoint(letter):
9.     if letter.capitalize() == 'T':
10.         return 0
11.     if letter.capitalize() == 'C':
12.         return 1
13.     if letter.capitalize() == 'R':
14.         return 2
15.     if letter.capitalize() == 'W':
16.         return 3
17.
18. def inttoletter(num):
19.     if num == 0:
20.         return 'T'
21.     if num == 1:
22.         return 'C'
23.     if num == 2:
24.         return 'R'
25.     if num == 3:
26.         return 'W'
27.
28.
29. # T C R W
30. #T
31. #C
32. #R
33. #W
34.
35. tablica = [
36. [0,0,0,0],
37. [0,0,0,0],
38. [0,0,0,0],
39. [0,0,0,0]
40. ]
41.
42.
43. def pobierz_rekord(input_string):
44.     record = input_string.split()
45.     row = lettertoint(record[0])
46.     cost = int(record[-1])
47.     del record[0]
48.     del record[-1]
49.     divider = len(record)
50.     for i in range(divider):
51.         tablica[lettertoint(record[i])][row] += cost/divider
52.     print('')
53.
54. def wypisz_tabele():
55.     print('\t\tT\tC\tR\tW')
56.     for i in range(len(tablica)):
57.         print(f'{inttoletter(i)} windykuje', end='\t')
58.         for j in range(len(tablica[0])):
59.             if i==j:
60.                 print('#',end='\t')
61.             else:
62.                 print(round(tablica[j][i], 2), end='\t')
63.         print('')
64.     print('')
65.
66. def podlicz(osoba):
67.     num = lettertoint(osoba)
68.     print(f'{osoba} windykuje', end='\t')
69.     for j in range(len(tablica[0])):
70.         if num==j:
71.                 print('#',end='\t')
72.         else:
73.             print(round(tablica[j][num]-tablica[num][j], 2), end='\t')
74.     print('')
75.
76.
77. while(True):
78.     input_string = input("<kupujący> <odbiorca1> <odbiorca2> <odbiorca3> ... <koszt>:")
79.     if input_string == 'p':
80.         break
81.     pobierz_rekord(input_string)
82.     wypisz_tabele()
83.
84.
85. print('\t\tT\tC\tR\tW')
86. podlicz('T')
87. podlicz('C')
88. podlicz('R')
89. podlicz('W')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top