-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson9.py
More file actions
26 lines (25 loc) · 1.31 KB
/
lesson9.py
File metadata and controls
26 lines (25 loc) · 1.31 KB
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
#Задача 1 Знаходимоо номер під'їзду та поверх знаючи номер квартири, кількість квартир на поверсі та кількість поверхів у будинку
from math import ceil
flatnumber, flatsonstore, stores= list(map(int, input().split()))
def address():
storeys=int(ceil(flatnumber/flatsonstore))
entry=int(ceil(storeys/stores))
store=storeys-((entry-1)*stores)
return (entry,store)
print(address())
# Задача 2 Малюємо ромб з непарної кількості зірочок
diamond=int(input('enter number of stars: '))
if diamond>0 and diamond%2:
a=['*'*i for i in range(1, diamond+1, 2)]
b=['*'*i for i in range(diamond, 0, -2)]
c=a+b[1:]
for i in c:
print(i.center(diamond))
# Задача 3 Перевырка строчок текстового файлу, роздылених на двы частини знаком ";" на відповідність умові
from sys import argv
with open(argv[1], 'r') as input_file:
for _ in input_file:
line=_.split(';')
line1=list(map(int, line[0].split()))
line2=list(map(int, line[1].split()))
print(line, sum(line1)//len(line1)==line2[0] and sum(line1)%len(line1)==line2[1])