Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import random
- from random import randint
- arr = []
- while True:
- try:
- n = int(input("Vavedi n: "))
- if(n < 30 or n > 100):
- print("Chisloto trqbva da e mejdu 30 i 100")
- break
- except ValueError:
- print("Vavedete chislo!")
- break
- except Exception:
- print("Nevalidni vhodni danni!")
- break
- minRandom = 20
- maxRandom = 600
- for _ in range(n):
- arr.append(randint(minRandom, maxRandom))
- kratni2 = 0
- minEl = maxRandom + 10
- minIndex = 0
- # 456 % 10 -> 6 % 2 == 0
- for i in range(len(arr)):
- if((arr[i] % 10) % 2 == 0):
- kratni2 = kratni2 + 1
- if(arr[i] % 7 == 3 and arr[i] < minEl):
- minIndex = i
- minEl = arr[i]
- print(f"Broi elementi, chiqto cifra na edinicite e kratna na 2: {kratni2}")
- print(f"Index na minimalen element, koito ima ostatuk 3 pri delenie na 7: {minIndex}")
- # 456 / 100 -> 4.56 -> 4
- # 456 % 100 -> 56 / 10 -> 5.6 -> 5
- arr2 = [num for num in arr if num // 100 == 3 or (num % 100) // 10 == 5]
- print(f"Arr2: {arr2}")
- maxEl = arr2[0]
- maxIndex = 0
- for i in range(1, len(arr2)):
- if(arr2[i] > maxEl):
- maxEl = arr2[i]
- maxIndex = i
- print(f"Indexa na elementa s max stoinost: {maxIndex}")
- proizvElEdinici3 = 1
- for i in range(len(arr2)):
- if(arr2[i] % 10 == 3):
- proizvElEdinici3 = proizvElEdinici3 * arr2[i]
- print(f"Proizv na elementite s cifra na edinicite 3: {proizvElEdinici3}")
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement