Skip to content
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

feat: random number generator #160

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
28 changes: 28 additions & 0 deletions src/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'''
Write a program that given two numbers as input make the main operations.

Output:
Insert first number: 4
Insert second number: 2

SUM: 6
Difference: 2
Multiplication: 8
Division: 2
'''
def calculator(first_number:int, second_number:int):
sum = first_number + second_number
difference = first_number - second_number
multiplication = first_number * second_number
if second_number != 0:
division = first_number / second_number
else:
division = "Can't divide by 0"
print(f"Sum: {sum}")
print(f"Difference: {difference}")
print(f"Multiplication: {multiplication}")
print(f"Division: {division}")

first:int = int(input("Insert first number: "))
second:int = int(input("Insert second number: "))
calculator(first, second)
9 changes: 9 additions & 0 deletions src/random-number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import random
Copy link

@simone989 simone989 Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importa solo la funzione randrange dal modulo random.

'''
anglruss0 marked this conversation as resolved.
Show resolved Hide resolved
Write a program that generates a random number.

Output:
The random number is: 4
'''
number = int(random.randrange(0,1000))

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=0
MAX_NUMBER= 1_000

print(f"The random number is: {number}")
Loading