Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ЗАДАЧА 1.
- /////////////////////////////////////////////////////////////////
- lst = []
- AmountOfNumbers = int(input('How many numbers: '))
- for n in range(AmountOfNumbers):
- numbers = int(input('Enter number '))
- lst.append(numbers)
- print("Biggest element in the list is :", max(lst))
- /////////////////////////////////////////////////////////////////
- ЗАДАЧА 2.
- /////////////////////////////////////////////////////////////////
- lst = []
- SumOfNumbers = int(input('Enter the numbers that you wish to sum: '))
- for n in range(SumOfNumbers):
- numbers = int(input('Enter a number: '))
- lst.append(numbers)
- print('The sum of the numbers is: ', sum(lst))
- ///////////////////////////////////////////////////////////////////
- ЗАДАЧА 3.
- //////////////////////////////////////////////////////////////////
- n = int(input("Enter the amount of rows for the triangle: "))
- for i in range(0, n):
- for j in range(0, i + 1):
- print("* ", end="")
- print()
- /////////////////////////////////////////////////////////////////
- ЗАДАЧА 4.
- /////////////////////////////////////////////////////////////////
- primeNumber = int(input("Enter a number: "))
- # prime numbers are greater than 1
- if primeNumber > 1:
- # check for factors
- for i in range(2, primeNumber):
- if (primeNumber % i) == 0:
- print(primeNumber, "is not a prime number")
- print(i, "times", primeNumber // i, "is", primeNumber)
- break
- else:
- print(primeNumber, "is a prime number")
- # if input number is less than
- # or equal to 1, it is not prime
- else:
- print(primeNumber, "is not a prime number")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement