Last active
March 30, 2021 19:32
-
-
Save serg1us/9d13414d1b84c3a0bd78a222a17e0654 to your computer and use it in GitHub Desktop.
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
Задание 1. (сделал с использование библиотеки -> import random, но тебе нужно спросить, можно ли использовать библиотеки | |
import random | |
a=int(input("Введите число A ")) | |
b=int(input("Введите число B ")) | |
randomness=[0,0,0,0,0,0,0,0,0,0] | |
for x in range(0,5): | |
randomness[x]=random.randint(min(a,b),max(a,b)) | |
randomness[x+5]=massiv[x]**2 | |
print(randomness) | |
Задание 2. | |
X, D = map(int, input().split()) | |
Array = [0,0,0,0,0] | |
Q = 0 | |
for i in range(5): | |
Array[i] = X + Q | |
Q += D | |
print(Array) | |
Задание 2. Можно решить с функцией range | |
n = int(input('Input n ')) #количетсво цифр | |
x = int(input('Input a[0] ')) #с какого числа начинать | |
d = int(input('Input d ')) #шаг прогрессии | |
print(*range(x, x + d * n, d)) | |
Задание 4. Здесь тоже функция, нужно уточнить, можно ли ими пользоваться | |
from random import randint | |
N = 5 | |
A = [ randint(0,5) | |
for i in range(N) ] | |
print(A) | |
count=0 | |
for i in range(len(A)-1): | |
if A[i]==A[i+1]: | |
count +=1 | |
print(count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment