-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path63.py
More file actions
43 lines (32 loc) · 876 Bytes
/
63.py
File metadata and controls
43 lines (32 loc) · 876 Bytes
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
# -*- coding: utf-8 -*-
import re
P = 2
H = 10
list_numbers = []
sum = 0
multiply = 1
count = 0
while True:
print("Введите число:", end=' ')
string = re.sub(r'[^0-9\-]+', '', input())
if len(string) == 0:
print("В строке не обнаружено числа")
continue
number = int(string)
list_numbers.append(number)
if number < P:
sum += number
elif number > H:
multiply *= number
if P < H:
if P < number < H:
count += 1
else:
if H < number < P:
count += 1
last_namber = list_numbers[len(list_numbers) - 1]
if last_namber == P or last_namber == H:
break
print("Сумма:", sum)
print("Произведение:", multiply)
print("Количество чисел в диапазоне значений P и H:", count)