Skip to content

Commit

Permalink
feat: random_array
Browse files Browse the repository at this point in the history
  • Loading branch information
irialcp committed Nov 8, 2023
1 parent c446327 commit 79f5d87
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/random_array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import random

def genera_array_numeri_random(numero_elementi, valore_minimo, valore_massimo):
return [random.randint(valore_minimo, valore_massimo) for _ in range(numero_elementi)]

numero_elementi = 10 # Numero di elementi nell'array
valore_minimo = 1 # Il valore minimo che può essere generato
valore_massimo = 15 # Il valore massimo che può essere generato

array_numeri_random = genera_array_numeri_random(numero_elementi, valore_minimo, valore_massimo)

numero_da_cercare = int(input('Inserisci il numero da cercare: '))

trovato = False

for numero in array_numeri_random:
if numero == numero_da_cercare:
trovato = True
break

if trovato:
print(f"Il numero {numero_da_cercare} è presente nell'array.")
else:
print(f"Il numero {numero_da_cercare} non è presente nell'array.")

0 comments on commit 79f5d87

Please sign in to comment.