This file contains hidden or 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
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
// Task 1 | |
// int main() { | |
// int a, b, S, P; | |
// cin >> a >> b; | |
// S = a * b; | |
// P = 2 * (a + b); |
This file contains hidden or 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
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
// int main() { | |
// double x1, y1, x2, y2, res; | |
// cin >> x1 >> y1; | |
// cin >> x2 >> y2; | |
// d = sqrt ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); |
This file contains hidden or 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 | |
numbers = [1, 3, 5, 7, 2, 4, 6, 8] | |
new_numbers = [] | |
chet = 0 | |
max_sum = 10 | |
for i in numbers: | |
if chet + i > max_sum: | |
print(new_numbers) | |
new_numbers.clear() | |
chet = 0 |
This file contains hidden or 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
numbers = [67, 43, 15, 0, 3, 4, 2, 1] ; print(f'Оригинальный список {numbers}') | |
numbers.append(99) ; print(f'Использовали append(99): {numbers}') | |
numbers.insert(2, 77) ; print(f'Использовали insert(77): {numbers}') | |
numbers.remove(77) ; print(f'Использовали remove(77): {numbers}') | |
last_element = numbers.pop() ; print(f'Использовали pop() {numbers}') | |
numbers1 = [1, 2, 3] | |
numbers2 = [4, 5, 6] | |
combined_list = numbers1 + numbers2 ; print(f'Слияние: {numbers1} + {numbers2} = {combined_list}') | |
copy_list = numbers.copy() ; print(f'Копия списка: {copy_list}') | |
copy_list.sort() ; print(f'Сортировка sort(): {copy_list}') |
This file contains hidden or 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
''' | |
size = 9 | |
for i in range(size): | |
for j in range(size): | |
print("*", end=" ") | |
print() | |
''' | |
''' | |
size = 9 | |
for i in range(size): |
This file contains hidden or 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
''' | |
№6 | |
num = int(input()) | |
s = [] | |
while num > 0: | |
s.append(num % 10) | |
num = num // 10 | |
print('Самая большая цифра:', max(s,), end=', ') | |
print('Самая маленькая цифра:', min(s)) | |
''' |
This file contains hidden or 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 | |
N = int(input("введите число: ")) | |
N += 1 | |
a = 0 | |
for i in range(N): | |
a += i | |
print(a) | |
''' | |
''' |
This file contains hidden or 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 | |
x = int(input("Введите число: ")) | |
y = 1 | |
while True: | |
z = x * y | |
print(x, '*', y, '=', z) | |
z += 1 | |
if z >= 50: | |
break | |
Задача №2 |
This file contains hidden or 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 | |
begin = int(input("Введите начало диапазона: ")) | |
end = int(input("Введите конец диапазона: ")) | |
a = 0 | |
while begin <= end: | |
a += begin | |
print(a) | |
begin += 1 | |
''' |
This file contains hidden or 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 | |
n = int(input("Введите число: ")) | |
if n % 2 == 0: | |
print("Число четное") | |
if n % 5 == 0: | |
print("Число кратно пяти") | |
if n % 2 != 0 and n % 5 != 0: | |
print("Число не четное и не кратно пяти") | |
''' |
NewerOlder