Created
October 17, 2022 11:06
-
-
Save bannovGB/60d8690631fda5dbbeb17ea74cacc859 to your computer and use it in GitHub Desktop.
Python ДЗ4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Вычислить число c заданной точностью d | |
Пример: при $d = 0.001, π = 3.141.$ $10^{-1} ≤ d ≤10^{-10}$''' | |
import math | |
d = input('Введите точность d ') | |
print('с округлением', round(math.pi, (len(d)-2))) | |
print('без округления', str(math.pi)[:len(d)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Задайте натуральное число N. Напишите программу, которая составит список простых множителей числа N.''' | |
n=int(input("N: ")) | |
i = 2 | |
lst = [] | |
while i * i <= n: | |
while n % i == 0: | |
lst.append(i) | |
n = n / i | |
i = i + 1 | |
if n > 1: | |
lst.append(int(n)) | |
print(lst) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Задайте последовательность чисел. Напишите программу, которая выведет список | |
неповторяющихся элементов исходной последовательности''' | |
import random | |
n=int(input("Введите размер массива: ")) | |
lst = [] | |
for i in range(n): | |
lst.append(random.randint(1, 10)) | |
print(lst) | |
lst2 = [] | |
for i in lst: | |
if lst.count(i) == 1: | |
lst2.append(i) | |
print(lst2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment