MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / get_avg

Function get_avg

other/guess_the_number_search.py:58–76  ·  view source on GitHub ↗

Return the mid-number(whole) of two integers a and b >>> get_avg(10, 15) 12 >>> get_avg(20, 300) 160 >>> get_avg("abcd", 300) Traceback (most recent call last): ... TypeError: can only concatenate str (not "int") to str >>> get_avg(10.5,50.25) 30

(number_1: int, number_2: int)

Source from the content-addressed store, hash-verified

56
57
58def get_avg(number_1: int, number_2: int) -> int:
59 """
60 Return the mid-number(whole) of two integers a and b
61
62 >>> get_avg(10, 15)
63 12
64
65 >>> get_avg(20, 300)
66 160
67
68 >>> get_avg("abcd", 300)
69 Traceback (most recent call last):
70 ...
71 TypeError: can only concatenate str (not "int") to str
72
73 >>> get_avg(10.5,50.25)
74 30
75 """
76 return int((number_1 + number_2) / 2)
77
78
79def guess_the_number(lower: int, higher: int, to_guess: int) -> None:

Callers 1

guess_the_numberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected