Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1fedd78
Create guess_the_number_search.py
hakiKhuva Nov 1, 2022
aa3b2da
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 1, 2022
df9f802
Update guess_the_number_search.py
hakiKhuva Nov 1, 2022
7d3956e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 1, 2022
55527cb
Update other/guess_the_number_search.py
hakiKhuva Nov 2, 2022
e20e616
Update other/guess_the_number_search.py
hakiKhuva Nov 2, 2022
aa5c12b
Update other/guess_the_number_search.py
hakiKhuva Nov 2, 2022
30fe325
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 2, 2022
7569539
added tests and added type checking statements
hakiKhuva Nov 2, 2022
3795571
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 2, 2022
9732e28
added tests and type checks for `guess_the_number`
hakiKhuva Nov 2, 2022
318a2f8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 2, 2022
b98d894
fixed the issues
hakiKhuva Nov 2, 2022
e007d45
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 2, 2022
44497b6
Update guess_the_number_search.py
cclauss Nov 2, 2022
29e8cd0
updated after running black
hakiKhuva Nov 2, 2022
ebc9800
Update guess_the_number_search.py
hakiKhuva Nov 2, 2022
9e411a1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 2, 2022
907d056
Update guess_the_number_search.py
hakiKhuva Nov 5, 2022
23fc205
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added tests and added type checking statements
  • Loading branch information
hakiKhuva authored Nov 2, 2022
commit 7569539af4200881974011130534cf477f82247e
32 changes: 32 additions & 0 deletions other/guess_the_number_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,53 @@ def temp_input_value(

>>> temp_input_value(option=False)
1000

>>> temp_input_value(min_val=100, option=True)
100

>>> temp_input_value(min_val=100, max_val=50)
Traceback (most recent call last):
...
ValueError: Invalid value for min_val or max_val (min_value < max_value)

>>> temp_input_value("ten","fifty",1)
Traceback (most recent call last):
...
AssertionError: Invalid type of value(s) specified to function!

>>> temp_input_value(min_val=-100, max_val=500)
-100

>>> temp_input_value(min_val=-5100, max_val=-100)
-5100
"""
assert type(min_val) == int and type(max_val) == int and \
type(option) == bool, \
"Invalid type of value(s) specified to function!"
if min_val > max_val:
raise ValueError(
"Invalid value for min_val or max_val (min_value < max_value)"
)
return min_val if option else max_val


def get_avg(number_1: int, number_2: int) -> int:
"""
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
"""
return int((number_1 + number_2) / 2)

Expand Down