def max_dist(n: int) -> float: max_dist = get_input('Укажите расстояние: ') for _ in range(1, n): dist = get_input('Укажите расстояние: ') if dist > max_dist: max_dist = dist return (max_dist)
def calc_grades(grade: int = 5) -> int: counter = 0 a = get_input('Введите оценку: ', False) while a == grade: counter += 1 a = get_input('Введите оценку: ', False) return (counter)
def max_speed(n: int = 20) -> float: max_speed = get_input('Укажите максимальную скорость: ') for _ in range(1, n): v = get_input('Укажите максимальную скорость: ') if v > max_speed: max_speed = v return (max_speed)
def max_num(n: int) -> float: n_max = get_input('Введите число: ') for _ in range(1, n): x = get_input('Введите число: ') if x > n_max: n_max = x return (n_max)
def max_temp(n: int = 30) -> float: max_temp = get_input('Укажите температуру: ') for _ in range(1, n): t = get_input('Укажите температуру: ') if t > max_temp: max_temp = t return (max_temp)
def min_max_num(n: int) -> tuple: n_max = get_input('Введите число: ') n_min = n_max for _ in range(1, n): x = get_input('Введите число: ') n_max, n_min = max(x, n_max), min(x, n_min) return (n_max, n_min)
def min_num(n: int) -> float: n_min = get_input('Введите число: ') for _ in range(1, n): x = get_input('Введите число: ') if x < n_min: n_min = x return (n_min)
def calc_fallout(moist: float = 0.0) -> int: counter = 0 m = get_input('Укажите число осадков: ') while m == moist: counter += 1 m = get_input('Укажите число осадков: ') return (counter)
def last_max_people(n:int) -> int: ind = 1 max_num = get_input('Укажите количество жильцов: ', False) for i in range(2, n+1): a = get_input('Укажите количество жильцов: ', False) if a >= max_num: ind = i return(ind)
def last_max(n:int) -> int: ind = 0 max_num = get_input('Введите число: ', False) for i in range(1, n): a = get_input('Введите число: ', False) if a >= max_num: ind = i return(ind)
def last_max_fall(n:int=30) -> int: ind = 0 max_num = get_input('Укажите количество осадков: ', False) for i in range(1, n): a = get_input('Укажите количество осадков: ', False) if a >= max_num: ind = i return(ind+1)
def first_div_seven() -> Union[int, bool]: i = 0 a = get_input('Введите число: ', False) while a != -1: i += 1 a = get_input('Введите число: ', False) if not a % 7: return (i) return (False)
def num_els() -> int: num_seq = 1 prev_a = get_input('Введите число: ') while prev_a != 1000: a = get_input('Введите число: ') if a == prev_a: num_seq += 1 prev_a = a return (num_seq)
def first_ends_seven() -> Union[int, bool]: i = 0 a = get_input('Введите число: ', False) while a != 100: i += 1 a = get_input('Введите число: ', False) if a % 10 == 7: return (i) return (False)
def first_demonia() -> Union[int, bool]: i = 0 a = get_input('Введите число: ', False) while a <= 100: i += 1 a = get_input('Введите число: ', False) if a == 666: return (i) return (False)
def change_sign(n: int) -> int: change_counter = 0 prev_a = get_input('Введите число: ', False) for x in range(n - 1): a = get_input('Введите число: ', False) if a * prev_a < 0: change_counter += 1 prev_a = a return (change_counter)
def num_seq_els() -> int: nums = [] prev_a = get_input('Введите число: ') while prev_a != 0: a = get_input('Введите число: ') if prev_a != a: nums.append(a) prev_a = a return (len(nums))
def num_duplicates(n: int = 20) -> int: num_seq = 1 prev_a = get_input('Введите число: ') for _ in range(1, n): a = get_input('Введите число: ') if a == prev_a: num_seq += 1 prev_a == a return (num_seq)
def neg_seq(n: int) -> int: seq_len = 0 msg = 'Введите число: ' a = get_input(msg) i = 1 while a < 0 and i < n: seq_len += 1 a = get_input(msg) i += 1 return (seq_len)
def calc_base_pairs(n: int) -> int: pairs = 0 a_i = get_input('Введите число', False) for _ in range(n): a = get_input('Введите число', False) if a_i == a: pairs += 1 else: a_i = a return (pairs)
def calc_end_five_pairs(n: int) -> int: pairs = 0 a_i = get_input('Введите число', False) for _ in range(n): a = get_input('Введите число', False) if a_i == a and a % 10 == 5: pairs += 1 else: a_i = a return (pairs)
def calc_accuracy(n: int, R: float, H: float, P: float) -> float: on_goal = 0 for _ in range(n): v_0 = get_input('Укажите начальную скорость: ') alpha = get_input('Укажите угол вылета снаряда: ') t = get_t(v_0, alpha, R) y_cord = calc_y_cord(v_0, alpha, t) if H <= y_cord <= P: on_goal += 1 return (round(on_goal / n, 5))
def first_neg_ind() -> Union[int, bool]: i = 0 a = get_input('Введите число: ') while a <= 100: i += 1 a = get_input('Введите число: ') if i == n: return(False) else: return(i)
def equal_seq(n: int) -> int: a = get_input('Введите число: ', False) b = get_input('Введите число: ', False) i = 0 counter = 0 while a == b and i < n: i += 1 b = get_input('Введите число: ', False) counter += 1 return (counter)
def max_num_seq(n: int) -> int: max_seq = 1 cur_seq = 1 prev_a = get_input('Введите число: ') for _ in range(1, n): a = get_input('Введите число: ') if a == prev_a: cur_seq += 1 else: prev_a = a max_seq = max(max_seq, cur_seq) cur_seq = 1 return (max_seq)
def find_max_el_cur(n: int = 20) -> int: max_el = 0 max_ind = 0 for i in range(n): r = get_input('Укажите сопротивление проводника: ') u = get_input('Укажите напряжение для проводника: ') el = calc_el_cur(r, u) if el > max_el: max_el = el max_ind = i return (max_ind)
def calc_max_speed(n:int=25) -> int: max_speed = 0 ind = 0 for i in range(n): s = get_input('Укажите пройденное расстояние: ') t = get_input('Укажите затраченное время: ') v = get_speed(s, t) if max_speed < v: max_speed = v ind = i return(ind)
def last_min_max_index(m: int) -> tuple: d = get_input('Введите число: ', False) min_ind = 0 max_ind = 0 min_num = d max_num = d for i in range(1, m): d = get_input('Введите число: ', False) if d >= max_num: max_num = d max_ind = i elif d <= min_num: min_num = d min_ind = i return (max_ind, min_ind)
def max_seq_len(n: int) -> int: max_seq_len = 1 seq_len = 1 prev_num = get_input('Введите число: ', False) for _ in range(1, n): d = get_input('Введите число: ', False) if not d % 2: if d == prev_num: seq_len += 1 else: seq_len = 1 prev_num = d if max_seq_len < seq_len: max_seq_len = seq_len return (max_seq_len)
def adj_max_seq(n:int) -> int: status = False max_seq = 1 cur_seq = 1 prev_a = get_input('Введите число: ') for _ in range(1, n): a = get_input('Введите число: ') if not status: if a > prev_a: status = 'u' else: status = 'd' cur_seq += 1 print('Status initialized! Counter on {}.'.format(cur_seq)) else: if status == 'u': if a > prev_a: cur_seq += 1 prev_a = a print('Status {}, counter on {}'.format(status, cur_seq)) else: prev_a = a max_seq = max(max_seq, cur_seq) cur_seq = 1 status = 'd' elif status == 'd': if a < prev_a: cur_seq += 1 prev_a = a print('Status {}, counter on {}'.format(status, cur_seq)) else: prev_a = a max_seq = max(max_seq, cur_seq) cur_seq = 1 status = 'u' max_seq = max(max_seq, cur_seq) return(max_seq)