📜 ⬆️ ⬇️

How to program a proverb?

Perhaps, it is possible to describe with the help of the program code almost everything that surrounds us. And well, that almost, it allows us not to immerse completely in the matrix. Yes, it is still quite difficult to program the behavior of individual politicians, because how can one describe something that defies logic? But wisdom, as a counterbalance to this, is possible.

image

The ancient wisdom that our people saved in the form of proverbs. It makes no sense to mention all the several thousand, especially since there are repeated among them. But the most famous I want to bring to the attention of readers Habra. Snake is taken as a language, since it is the only one I know.

First:
')
def wolf_sight_direction(food_amount): wolf_attraction_chance = 0 * food_amount if wolf_attraction_chance == 0 and food_amount == 0: print "No food. Wolf looks towards the forest" else: print food_amount, "food given. Wolf still looks towards the forest" for food_amount in range(42): wolf_sight_direction(food_amount) food_amount += 1 

Here you can experiment with the amount of food, but the result will be unchanged.

The second is a bit more complicated:

 def in_at(): forehead = True spelt = True return forehead and spelt print in_at() 

Returns True, confirming the correctness of the statement.

The third is a bit simpler:

 def wisdom(hair): return 42 - len(hair) print wisdom("Very long and curly blond haired specimen") print wisdom("Vasserman") 

Penultimate:

 class War: def __init__(self): self.definition = "KillThemAll" class Happiness: pass class Kitten: pass class Beauty: pass class WarChild(War): pass print issubclass(Happiness, War) print issubclass(Kitten, War) print issubclass(Beauty, War) print issubclass(WarChild, War) 

Cats need a house. And to live together, as with Leopold.

And last:

 import time timestamp = int(time.time()) if timestamp > 1488326399: pants = 2 else: pants = 1 print pants 

I hope we were able to solve all or even invent your own.

Happy friday

Source: https://habr.com/ru/post/318680/


All Articles