Skip to content

Commit 8e34b76

Browse files
committed
попытка 1
1 parent 0563d1a commit 8e34b76

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

lesson03/home_work/hw03_easy.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def my_round(n, nd):
9-
s = round(n,nd)
9+
s = float("{0:.{nd}f}".format(n,nd=nd))
1010
return s
1111

1212

@@ -22,9 +22,21 @@ def my_round(n, nd):
2222
# !!!P.S.: функция не должна НИЧЕГО print'ить
2323

2424
def lucky_ticket(ticket_number):
25-
pass
26-
27-
25+
repr_tic_num = repr(ticket_number)
26+
if len(repr_tic_num) == 6:
27+
left = repr_tic_num[:3]
28+
right = repr_tic_num[-3:]
29+
def sum_side(side):
30+
s = 0
31+
for i in side:
32+
s+=int(i)
33+
return s
34+
if sum_side(left)== sum_side(right):
35+
return "true"
36+
else:
37+
return "false"
38+
else:
39+
return "Билет не шестизначный"
2840
print(lucky_ticket(123006))
2941
print(lucky_ticket(12321))
3042
print(lucky_ticket(436751))

0 commit comments

Comments
 (0)