socek

Untitled

Dec 2nd, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.59 KB | None | 0 0
  1. # encoding: utf8
  2. from random import choice
  3.  
  4.  
  5. class DictList(object):
  6.     dictionary = [
  7.         'Nóż',
  8.         'Kaczka',
  9.         'Mepel',
  10.         'Krzesło',
  11.         'Pudło',
  12.         'Książka',
  13.         'Wieża',
  14.         'Laptop',
  15.         'Łóżko',
  16.         'Stół',
  17.         'Szafa',
  18.         'Dywan',
  19.         'Ryza papieru',
  20.         'Dom',
  21.         'Herbata',
  22.         'Jabłko',
  23.         'Mikrofon',
  24.         'Lampa',
  25.         'Głośniki',
  26.         'Butelka',
  27.         'Klawiatura',
  28.         'Plecak',
  29.         'Niebo',
  30.         'Łyżka',
  31.         'Kaloryfer',
  32.         'Telewizor',
  33.         'Steropian',
  34.         'Szczur',
  35.         'Zdjęcie',
  36.         'Mapa',
  37.         'Żelazko',
  38.         'Karimata',
  39.         'Budzik',
  40.         'Długopis',
  41.         'Zegarek',
  42.         'biurko',
  43.         'okno',
  44.         'anioł',
  45.         'wiadro',
  46.         'obraz',
  47.     ]
  48.  
  49.     def __init__(self):
  50.         self.deck = list(range(len(self.dictionary)))
  51.  
  52.     def all(self):
  53.         while len(self.deck):
  54.             number = choice(self.deck)
  55.             self.deck.remove(number)
  56.             yield (number + 1, self.dictionary[number])
  57.  
  58.  
  59. def run():
  60.     print('Przeprowadzamy test')
  61.     dictionary = DictList()
  62.     for number, name in dictionary.all():
  63.         print('\nPodaj słowo dla %d (pozostało %d)' % (number, len(dictionary.deck)))
  64.         inputed = input('--> ').strip().lower()
  65.         name = name.lower()
  66.         if inputed == name:
  67.             print('Dobrze!')
  68.         else:
  69.             print('Źle, powinno być "%s"!' % (name,))
  70.  
  71. if __name__ == '__main__':
  72.     run()
Advertisement
Add Comment
Please, Sign In to add comment