From 99a69b1a988820324142dce885f2bfe7b37034fa Mon Sep 17 00:00:00 2001 From: Aleksey Zubakov Date: Tue, 27 Sep 2022 01:49:43 +0300 Subject: [PATCH] Code from first seminar. There is not that much of code, but anyway. --- 01/01.py | 27 +++++++++++++++++++++++++++ 01/README.md | 10 ++++++++++ 01/list.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 01/01.py create mode 100644 01/README.md create mode 100644 01/list.py diff --git a/01/01.py b/01/01.py new file mode 100644 index 0000000..fdef2ee --- /dev/null +++ b/01/01.py @@ -0,0 +1,27 @@ +import antigravity # попробуй + +import this + +# stdout: +# +# The Zen of Python, by Tim Peters +# +# Beautiful is better than ugly. +# Explicit is better than implicit. +# Simple is better than complex. +# Complex is better than complicated. +# Flat is better than nested. +# Sparse is better than dense. +# Readability counts. +# Special cases aren't special enough to break the rules. +# Although practicality beats purity. +# Errors should never pass silently. +# Unless explicitly silenced. +# In the face of ambiguity, refuse the temptation to guess. +# There should be one-- and preferably only one --obvious way to do it. +# Although that way may not be obvious at first unless you're Dutch. +# Now is better than never. +# Although never is often better than *right* now. +# If the implementation is hard to explain, it's a bad idea. +# If the implementation is easy to explain, it may be a good idea. +# Namespaces are one honking great idea -- let's do more of those! diff --git a/01/README.md b/01/README.md new file mode 100644 index 0000000..d12d982 --- /dev/null +++ b/01/README.md @@ -0,0 +1,10 @@ +### Как запускать? + +Запустить интерпретатор Python с указанием пути до скрипта. + +Достаточно указать имя файла, находясь в директории + + +```sh + +``` diff --git a/01/list.py b/01/list.py new file mode 100644 index 0000000..88f3a00 --- /dev/null +++ b/01/list.py @@ -0,0 +1,47 @@ +a = ["one", "two", "three"] + +a[2] + " people" +"three people" + +a + [2, 3] +["one", "two", "three", 2, 3] + +a.append(True) +print(a) +["one", "two", "three", True] + +a.extend([4]) + +a +["one", "two", "three", True, 4] + +a.insert(0, "zero") # Почему плохо? + +a +["zero", "one", "two", "three", True, 4] + +a = ["one", "two", "three", "for"] +a[1:3:2] +["two"] + +a[::2] +["one", "three"] + +a[0:2] = [] +a +["three", "for"] + +a = ["one", "two", "three", "for"] + +a.remove(152) + +# ValueError Traceback (most recent call last) ----> 1 a.remove(152) +# ValueError: list.remove(x): x not in list +a.index("one") +0 + +"two" in a +True + +len(a) +4