-
Notifications
You must be signed in to change notification settings - Fork 79
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
Random number #178
Random number #178
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from random import randint | ||
|
||
def random_number(min: int, max: int) -> int: | ||
return randint(min, max) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from src.random_number import random_number | ||
|
||
def test_random_number() -> None: | ||
t = random_number(0, 100) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dai un nome più "parlante" alla variabile There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definisci delle variabili costanti che contengano 0 e 100. |
||
assert t >= 0 and t <= 100 | ||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Volendo potresti mettere questo test in un ciclo giusto per fargli fare un po' di passate e vedere piu' output, ma essendo random in principio non cambia tantissimo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il nome delle variabili in questa maniera e' estremamente esplicito, pero' c'e' il problema che vanno a sovrascrivere (e quindi nascondere) le funzioni built-in di python,
max
emin
, che quindi non potresti andare ad utilizzare all'interno della funzione.Potresti quindi optare per nomi alternativi come
min_value
ominimum
opuffo
. Magari non l'ultimo. A meno che tu non sia Barbanera.