Skip to content

Create guess_the_number_search.py #7937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
May 17, 2023
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
21 changes: 12 additions & 9 deletions other/guess_the_number_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ def temp_input_value(
>>> 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!"
assert isinstance(min_val, int) and isinstance(max_val, int) and \
isinstance(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)")
raise ValueError(
"Invalid value for min_val or max_val (min_value < max_value)"
)
return min_val if option else max_val


Expand Down Expand Up @@ -148,14 +150,15 @@ def guess_the_number(lower: int, higher: int, to_guess: int) -> None:
...
ValueError: argument value for lower and higher must be(lower > higher)
"""
assert (
type(lower) == int and type(higher) == int and type(to_guess) == int
), 'argument values must be type of "int"'
assert isinstance(lower, int) and isinstance(higher, int) \
and isinstance(to_guess, int), "argument values must be type of \"int\""

if lower > higher:
raise ValueError("argument value for lower and higher must be(lower > higher)")
raise ValueError(
"argument value for lower and higher must be(lower > higher)"
)

if to_guess < lower or to_guess > higher:
if not lower < to_guess < higher:
raise ValueError(
"guess value must be within the range of lower and higher value"
)
Expand Down