Skip to content

Instantly share code, notes, and snippets.

@mariamyzz
mariamyzz / extract_links.py
Last active June 30, 2017 04:52
Maria Myznikova's homework #9
@mariamyzz
mariamyzz / decorators.py
Last active June 22, 2017 16:43
Maria Myznikova's Homework #7
from functools import wraps
from time import time
def cancelled(func):
"""Cancels the execution of a function"""
@wraps(func)
def wrapped(*args, **kwargs):
print(func.__name__, 'is cancelled!')
return wrapped
@mariamyzz
mariamyzz / Animal.py
Last active June 16, 2017 08:48
Maria Myznikova's homework #5
from random import choice
class Animal:
def __init__(self):
self.species = choice(['those that belong to the emperor',
'predators', 'venomous', 'poisonous',
'snappish', 'vegetarian', 'fluffy',
'domestic', 'those that, at a distance, resemble flies'])
@mariamyzz
mariamyzz / noughts_and_crosses.py
Last active June 10, 2017 14:24
Maria Myznikova's Homework #4
# -*- coding: utf-8 -*-
import random
import sys
NOUGHT = 'O'
CROSS = 'X'
EMPTY_SLOT = '_'
MOVES = [str(x) for x in range(1, 10)]
@mariamyzz
mariamyzz / game.py
Last active June 9, 2017 07:09
Maria Myznikova's Homework #3, the Game
# -*- coding: utf-8 -*-
# `random` module is used to shuffle field, see§:
# https://docs.python.org/3/library/random.html#random.shuffle
import random
import sys
# Empty tile, there's only one empty cell on a field:
EMPTY_MARK = 'x'
@mariamyzz
mariamyzz / hw3_args_1.py
Last active June 8, 2017 04:21
Maria Myznikova's homework#3, the simple part
# Написать функцию, которая принимает любое количество аргументов чисел.
# Среди них она находит максимальное и минимальное. И возвращает оба
def max_and_min(*arg):
return sorted(arg)[-1], sorted(arg)[0]
@mariamyzz
mariamyzz / mariamyz_homework2.py
Last active June 6, 2017 11:45
Maria Myznikova's Homework #2
# 1
mylist = [2, 54345, 55**5, 63**.5, 3.1415926, 10, 111111]
sorted(mylist)
# 2
d = {}
for i in range(22, 99, 11):
d[i] = str(i)
print(d.get(i), d[i])
@mariamyzz
mariamyzz / mariamyz_homework1.py
Last active June 29, 2018 11:48
Maria Myznikova's homework for lesson 1
questions_pull = [
'What is a name of a interpreted programming language, created by Guido van Rossum, which philosophy emphasizes code readability?',
'All the next questions are by chance related to Python as well. So, what is a statement which executes a block of code as long as its condition is true?',
'What is a boolean operator which returns "False" only if all the operands equal "False"?',
'How does the exponentiation operator look?',
'From what number does Python start all its indexing?',
'What function do we use to try to transform the string to an integer number?',
'What function do we use to display some text to a user?',
'If we have "print(\'string\'[0])" executed, what do we expect to see?',
'What do you think you\'ll see if you execute "print(len(\'7 chars\'))"?',