{"id":2280,"date":"2019-07-13T11:14:36","date_gmt":"2019-07-13T09:14:36","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=2280"},"modified":"2019-07-28T13:00:50","modified_gmt":"2019-07-28T11:00:50","slug":"memory-game-with-python-in-no-time","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/memory-game-with-python-in-no-time\/","title":{"rendered":"Memory game with Python in no time"},"content":{"rendered":"<p>13\/07\/2019<\/p>\n<p>Do you want to learn long list of names having fun? I got the program for you. You can build your own when you want changing the list of names you want to learn. In the following example, explained in the video, I will show you how to create the program to help people to memorize list of names having fun. The example, in particular, will test your memory about the countries that uses the euro as their country money. As you know there are several countries that uses euro, but not all the european countries uses them. So, which is the best way than a test to ensure that you remember them all? But you can substitute the list whith anything else you want and also compare it with your friends result as a game.<\/p>\n<p>How to memorize lists of names in the most effective and fun way with a couple of lines of code in Python. In 3 minutes (even less) you will be able to create this program, understanding lists, list comprehension, for loops, the use of print and input. With a very basic knowledge of Python you can get a lot of fun (and learning). You will be able to create a lot of memory games to test yourself and your friends ability in memorizing stuffs.<\/p>\n<p><iframe loading=\"lazy\" title=\"Memory Game with Python in no time\" width=\"747\" height=\"420\" src=\"https:\/\/www.youtube.com\/embed\/0q1ibOItQnk?feature=oembed&amp;enablejsapi=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>The code of the memory game<\/h2>\n<p>Here is the code that you have seen in the video about making a game to test your memory about list of names. In this example you have to mermorize the countries that uses the euro currency.<\/p>\n<p>The program uses the SAPI.SpVoice of Windows 10 to make the computer speak during the game.<\/p>\n<pre class=\"lang:default decode:true\">import sys\r\nfrom win32com.client import Dispatch\r\nspeak = Dispatch(\"SAPI.SpVoice\")\r\nls = sorted(\"\"\"\r\nAustria\r\nItalia\r\nGermania\r\nFrancia\r\nLussemburgo\r\nGrecia\r\nSpagna\r\nPortogallo\r\nMalta\r\nCipro\r\nLettonia\r\nLituania\r\nEstonia\r\nFinlandia\r\nSlovacchia\r\nSlovenia\r\nIrlanda\r\nPaesi Bassi\"\"\".split(\"\\n\")[1:])\r\n\r\ndef start():\r\n\tprint(\"I paesi dell'Euro sono:\\n\")\r\n\r\n\tfor paese in ls:\r\n\t\tprint(paese[0] + \".\"*(len(paese)-2) + paese[-1])\r\n\t\tx = input(paese[0])\r\n\t\tif paese[0] + x == paese:\r\n\t\t\t#print(ls.index(paese) + 1)\r\n\t\t\tspeak.Speak(paese)\r\n\t\t\tcontinue\r\n\t\telse:\r\n\t\t\tprint(\"Mi spiace, hai sbagliato\")\r\n\t\t\tprint(\"Dovevi scrivere:\" + paese)\r\n\t\t\tprint(\"Punti: \" + str(paese.index(paese)))\r\n\t\t\ty = input(\"Vuoi riprovare?\")\r\n\t\t\tif y in \"Si SI si s\u00ec S\u00ec\".split():\r\n\t\t\t\tstart()\r\n\t\t\telse:\r\n\t\t\t\tprint(\"Riprova... il tuo punteggio \u00e8 \" + str(ls.index(paese)))\r\n\t\t\t\tbreak\r\n\tprint(\"Bravo... il tuo punteggio \u00e8 \" + str(ls.index(paese)))\r\n\r\n\r\nstart()\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"How to memorize lists of names in the most effective and fun way with a couple of lines of code in Python\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/memory-game-with-python-in-no-time\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":2281,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[154],"tags":[467,466,465,60,441,4],"class_list":["post-2280","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-games","tag-console-game","tag-create-game","tag-euro","tag-list","tag-memory-game","tag-python"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":false,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=2280"}],"version-history":[{"count":4,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2280\/revisions"}],"predecessor-version":[{"id":2537,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2280\/revisions\/2537"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/2281"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=2280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=2280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=2280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}