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
print("Before:") | |
A = [[ '#' ' ' [(col + cell) % 2] for col in range(5)] for cell in range(5)] | |
print(A) | |
print("After:") | |
A = [] | |
for col in range(5): | |
A.append([]) | |
for cell in range(5): | |
check = (col + cell) % 2 |
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
def test(i): | |
s = i / 5 | |
ostatok = s - int(s) | |
if ostatok == 0: | |
print(str(i) + " делится на пять, без остатка") | |
print(10) | |
test(10) |
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
# квадраный корень 10 | |
y = float(input("Your number, please: ")) | |
y2 = y | |
count = 0 | |
for i in range(0,100): | |
y2 = y2 / 2 | |
count += 1 | |
print(y2) |
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
#!/bin/env python3 | |
dark = True | |
for col in range(5): | |
for cell in range(5): | |
if dark: | |
print("[" + str(col) + "/" + str(cell) + " is dark] ", end='') | |
print() |
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
[#][ ][#][ ][#] | |
[ ][#][ ][#][ ] | |
[#][ ][#][ ][#] | |
[ ][#][ ][#][ ] | |
[#][ ][#][ ][#] |
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
for column in range(3): | |
print(str(column) + '---> ', end='') | |
for cell in range(5): | |
print('[' + str(cell) + '] ', end='') | |
print('~~~') | |
# Результат: | |
''' | |
0---> [0] [1] [2] [3] [4] ~~~ | |
1---> [0] [1] [2] [3] [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
import random | |
guess = random.randint(0,100) | |
print(guess) |
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
x=13 # присваиваем переменной число 13- как часы ## Саша: можно сразу hour вместо x. На 11 строчке hour тоже используется и в тех же целях, так что не нужно двух переменных для этого. | |
s=00 # присваиваем переменной число 00- как отсчет секунд. ## Саша: 00 тоже самое что и 0. чтобы двойной 0 печатать (а так же 01, 02, ...) нужно if использовать. if sec < 10: ... | |
for s in range(100): # для секунд в диапазоне 100 | |
print(str(x) + “:” + str(s)) # вывести секунды, как строку , двоеточие, для правильного отображения времени и секунды как строку. | |
if s>58: # если секунда меньше 58, то остановить цикл. будет идти от 0 до 59 ( а почему?????). ## Саша: по шагам: 1. строчка 5, s меняется с 58 на 59; 2. строчка 6, печатает 13:59; 3. строчка 7, s>58 первый раз становится правдой (true) | |
break # остановка цикла ## Саша: хорошое владение if'ом и break'ом. Можно упростить, здесь тоже самое можно сделать поменяв на range(60) на 5ой строчке. но |
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
#!/bin/env python | |
n = int(input("Enter a integer: ")) | |
total = 0 # к этой будем прибавлять | |
print(n) | |
for i in range(1, n + 1): # прибавлять будем i, которая сначала 1, | |
# потом 2, и так до n. у функции range() | |
# второй аргумент всегда на один |
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
#!/bin/env python3 | |
import os | |
import sys | |
data_dir = "checker-data" | |
try: | |
os.mkdir(data_dir) | |
except FileExistsError: | |
pass |
NewerOlder