Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # In input una lista di numeri float
- # 2 liste
- # 1 Con tutti i positivi > 0
- # 1 Con tutti i negativi < 0
- # Contare tutti gli zero
- # 1 0 9 0 7 -1 -9 0 6 5 -1
- # 1 9 7 6 5
- # -1 -9 -1
- # 3
- def main():
- n = int(input("N: "))
- nums = leggi_numeri(n)
- # print(nums)
- print("i positivi sono :", positivi(nums))
- print("i negativi sono :", negativi(nums))
- print("gli zeri sono :", numero_zeri_marco(nums))
- def leggi_numeri(numero_punti_da_leggere):
- lista_punti = []
- punti_gia_letti = 0
- while (punti_gia_letti < numero_punti_da_leggere):
- x = float(input("X: "))
- lista_punti.append(x)
- punti_gia_letti = punti_gia_letti + 1
- return lista_punti
- def positivi(numeretti):
- lista_punti = []
- i = 0
- while(i < len(numeretti)):
- if(numeretti[i] > 0):
- lista_punti.append(numeretti[i])
- i = i + 1
- return lista_punti
- def negativi(numeretti):
- lista_punti = []
- i = 0
- while(i < len(numeretti)):
- if(numeretti[i] < 0):
- lista_punti.append(numeretti[i])
- i = i + 1
- return lista_punti
- def numero_zeri(numeretti):
- numero_zeri = 0
- i = 0
- while(i < len(numeretti)):
- if(numeretti[i] == 0):
- numero_zeri = numero_zeri + 1
- i = i + 1
- return numero_zeri
- def numero_zeri_marco(numeretti):
- lista_punti = []
- i = 0
- while(i < len(numeretti)):
- if(numeretti[i] == 0):
- lista_punti.append(numeretti[i])
- i = i + 1
- return len(lista_punti)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement