-
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
Created a new file named randomNumber.py #113
Conversation
tests/calculator.py
Outdated
print("\nThe sum is:",int(x) + int(y)) | ||
print("The difference is:", int(x)- int(y)) | ||
print("The multiplication is: ", int(x) * int(y)) | ||
print("The division is: ", float(x)/float(y)) |
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.
Aggiungi un blocco try/except per gestire le eccezioni che potrebbero essere scatenate da questo operatore.
tests/calculator.py
Outdated
print("\nThe sum is:",int(x) + int(y)) | ||
print("The difference is:", int(x)- int(y)) | ||
print("The multiplication is: ", int(x) * int(y)) | ||
print("The division is: ", float(x)/float(y)) |
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.
Stai eseguendo il casting a int/float molteplici volte, fallo una volta sola in fase di definizione.
tests/randomNumber.py
Outdated
@@ -0,0 +1,3 @@ | |||
import random |
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.
Importa solo la funzione randint dal modulo random.
tests/randomNumber.py
Outdated
@@ -0,0 +1,3 @@ | |||
import random | |||
|
|||
print("Your random number is:", random.randint(1,100)) |
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.
Definisci sempre i valori costanti in opportune variabili.
MIN_NUMBER=1
MAX_NUMBER= 100
tests/verify.py
Outdated
|
||
number = input("Enter a number to check if is present in the array:") | ||
|
||
if int(number) in array: |
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.
Effettua il casting ad int in fase di definizione/assegnazione della variabile.
No description provided.