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
| import random | |
| def main(): | |
| while True: | |
| a, b = random.randint(1, 10), random.randint(1, 10) | |
| expr = "{} + {}".format(a, b) | |
| print "What is {}?".format(expr) | |
| try: | |
| given_answer = int(raw_input('> ')) |
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
| """ | |
| Generate a stream of characters that look like rain drops. | |
| """ | |
| import random | |
| import time | |
| class Bullet(object): | |
| def __init__(self, pos=0, char='*', speed=1): | |
| self.pos = pos |
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
| import collections | |
| import random | |
| def gen_ngrams(letters, n=2): | |
| ngram = collections.deque([None] * n, n) | |
| for letter in letters: | |
| ngram.append(letter) | |
| yield tuple(ngram) | |
| ngram.append(None) |
OlderNewer