{"id":603,"date":"2016-07-06T11:14:49","date_gmt":"2016-07-06T11:14:49","guid":{"rendered":"http:\/\/learnlearn.uk\/microbit\/?p=603"},"modified":"2016-07-06T12:57:59","modified_gmt":"2016-07-06T12:57:59","slug":"the-friendship-test","status":"publish","type":"post","link":"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/","title":{"rendered":"The Friendship test"},"content":{"rendered":"\n<div class=\"arconix-tabs-horizontal\"><ul class=\"arconix-tabs\"><li data-arconix-icon=\" \" data-arconix-color=\" \" class=\"arconix-tab tab-Introduction\"><a class=\"\" href=\"#tab-Introduction\">Introduction<\/a><\/li>\n<li data-arconix-icon=\" \" data-arconix-color=\" \" class=\"arconix-tab tab-Pythoncode\"><a class=\"\" href=\"#tab-Pythoncode\">Python code<\/a><\/li><\/ul>\n<div class=\"arconix-panes\"><div class=\"arconix-pane pane-Introduction\">\n<p>The aim of the this project is to find out how good a friend your friend is, by asking them a number of questions. The Microbit keeps track of their answer each time and will give them a friendship score percentage at the end<\/p>\n<\/div>\n<div class=\"arconix-pane pane-Pythoncode\">\n<p>In this program we will be using Python coding.<\/p>\n<p>You can access the Python Microbit &#8216;Create Code&#8217; link below.<\/p>\n<a href='https:\/\/www.microbit.co.uk\/app\/#create:xyelfe' class='arconix-button arconix-button-medium arconix-button-gray' target=\"_blank\" >Micropython Microbit Create Code<\/a>\n<div class=\"arconix-toggle-wrap\"><div class=\"arconix-toggle-title toggle-closed\"><i class='fa fa-plus-square'><\/i>Click for code<\/div><div class=\"arconix-toggle-content\">\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #ff0000; background-color: #ffaaaa;\">#<\/span> This project is designed to test how good a friend you are\r\n<span style=\"color: #ff0000; background-color: #ffaaaa;\">#<\/span> by asking you a number of questions about your friend.\r\nfrom microbit <span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #333333;\">*<\/span>\r\n\r\nquestions <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">\\<\/span>\r\n[[<span style=\"background-color: #fff0f0;\">\"Is my favourite colour A - red or B - green?\"<\/span>,<span style=\"background-color: #fff0f0;\">\"B\"<\/span>],\r\n[<span style=\"background-color: #fff0f0;\">\"Is my favourite food A - Pizza or B - Spaghetti?\"<\/span>,<span style=\"background-color: #fff0f0;\">\"B\"<\/span>],\r\n[<span style=\"background-color: #fff0f0;\">\"Is my cat's name A - Meg or B - Smeg\"<\/span>,<span style=\"background-color: #fff0f0;\">\"A\"<\/span>]]\r\n\r\nscore <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">for<\/span> question <span style=\"color: #008800; font-weight: bold;\">in<\/span> questions<span style=\"color: #333333;\">:<\/span>\r\n    display.scroll(question[<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>])\r\n    <span style=\"color: #008800; font-weight: bold;\">while<\/span> True<span style=\"color: #333333;\">:<\/span>\r\n        <span style=\"color: #008800; font-weight: bold;\">if<\/span> button_a.is_pressed()<span style=\"color: #333333;\">:<\/span>\r\n            guess <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"A\"<\/span>\r\n            <span style=\"color: #008800; font-weight: bold;\">break<\/span>\r\n        elif button_b.is_pressed()<span style=\"color: #333333;\">:<\/span>\r\n            guess <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"B\"<\/span>\r\n            <span style=\"color: #008800; font-weight: bold;\">break<\/span>\r\n        elif accelerometer.was_gesture(<span style=\"background-color: #fff0f0;\">\"shake\"<\/span>)<span style=\"color: #333333;\">:<\/span>\r\n            display.scroll(question[<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>])\r\n        \r\n        sleep(<span style=\"color: #0000dd; font-weight: bold;\">10<\/span>)\r\n        \r\n    <span style=\"color: #008800; font-weight: bold;\">if<\/span> guess <span style=\"color: #333333;\">==<\/span> question[<span style=\"color: #0000dd; font-weight: bold;\">1<\/span>]<span style=\"color: #333333;\">:<\/span>\r\n        display.scroll(<span style=\"background-color: #fff0f0;\">\"Correct...\"<\/span>)\r\n        score <span style=\"color: #333333;\">+=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>\r\n    <span style=\"color: #008800; font-weight: bold;\">else<\/span><span style=\"color: #333333;\">:<\/span>\r\n        display.scroll(<span style=\"background-color: #fff0f0;\">\"Wrong....\"<\/span>)\r\n    \r\n    display.scroll(<span style=\"background-color: #fff0f0;\">\"Score:\"<\/span> <span style=\"color: #333333;\">+<\/span> str(score))\r\n\r\ndisplay.scroll(<span style=\"background-color: #fff0f0;\">\"Your friendship score is \"<\/span> <span style=\"color: #333333;\">+<\/span> str((score<span style=\"color: #333333;\">\/<\/span>len(questions))<span style=\"color: #333333;\">*<\/span><span style=\"color: #0000dd; font-weight: bold;\">100<\/span>) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">\"%\"<\/span> )\r\n<\/pre>\n<\/div>\n<\/div><\/div>\n<\/div><\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":610,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":""},"categories":[2],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The Friendship test - Microbit - LearnLearn.co.uk<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Friendship test - Microbit - LearnLearn.co.uk\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/\" \/>\n<meta property=\"og:site_name\" content=\"Microbit\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-06T11:14:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-07-06T12:57:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship.png\" \/>\n\t<meta property=\"og:image:width\" content=\"439\" \/>\n\t<meta property=\"og:image:height\" content=\"391\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"learnlearnadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"learnlearnadmin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/\"},\"author\":{\"name\":\"learnlearnadmin\",\"@id\":\"https:\/\/learnlearn.uk\/microbit\/#\/schema\/person\/37d61760b611e12d655e20de44b12f02\"},\"headline\":\"The Friendship test\",\"datePublished\":\"2016-07-06T11:14:49+00:00\",\"dateModified\":\"2016-07-06T12:57:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/\"},\"wordCount\":100,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/learnlearn.uk\/microbit\/#organization\"},\"articleSection\":[\"projects\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/\",\"url\":\"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/\",\"name\":\"The Friendship test - Microbit - LearnLearn.co.uk\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/microbit\/#website\"},\"datePublished\":\"2016-07-06T11:14:49+00:00\",\"dateModified\":\"2016-07-06T12:57:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Microbit Unit Home\",\"item\":\"https:\/\/learnlearn.uk\/microbit\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Friendship test\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnlearn.uk\/microbit\/#website\",\"url\":\"https:\/\/learnlearn.uk\/microbit\/\",\"name\":\"Microbit\",\"description\":\"Tutorials, Projects &amp; Challenges\",\"publisher\":{\"@id\":\"https:\/\/learnlearn.uk\/microbit\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnlearn.uk\/microbit\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/learnlearn.uk\/microbit\/#organization\",\"name\":\"Microbit\",\"url\":\"https:\/\/learnlearn.uk\/microbit\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/learnlearn.uk\/microbit\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2019\/06\/LearnLearnLogowhite.png\",\"contentUrl\":\"https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2019\/06\/LearnLearnLogowhite.png\",\"width\":710,\"height\":98,\"caption\":\"Microbit\"},\"image\":{\"@id\":\"https:\/\/learnlearn.uk\/microbit\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/learnlearn.uk\/microbit\/#\/schema\/person\/37d61760b611e12d655e20de44b12f02\",\"name\":\"learnlearnadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/learnlearn.uk\/microbit\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/07a2ee7e04b8bee91a78709b019de541?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/07a2ee7e04b8bee91a78709b019de541?s=96&d=mm&r=g\",\"caption\":\"learnlearnadmin\"},\"url\":\"https:\/\/learnlearn.uk\/microbit\/author\/learnlearnadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Friendship test - Microbit - LearnLearn.co.uk","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/","og_locale":"en_GB","og_type":"article","og_title":"The Friendship test - Microbit - LearnLearn.co.uk","og_url":"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/","og_site_name":"Microbit","article_published_time":"2016-07-06T11:14:49+00:00","article_modified_time":"2016-07-06T12:57:59+00:00","og_image":[{"width":439,"height":391,"url":"https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship.png","type":"image\/png"}],"author":"learnlearnadmin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"learnlearnadmin","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/#article","isPartOf":{"@id":"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/"},"author":{"name":"learnlearnadmin","@id":"https:\/\/learnlearn.uk\/microbit\/#\/schema\/person\/37d61760b611e12d655e20de44b12f02"},"headline":"The Friendship test","datePublished":"2016-07-06T11:14:49+00:00","dateModified":"2016-07-06T12:57:59+00:00","mainEntityOfPage":{"@id":"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/"},"wordCount":100,"commentCount":0,"publisher":{"@id":"https:\/\/learnlearn.uk\/microbit\/#organization"},"articleSection":["projects"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/","url":"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/","name":"The Friendship test - Microbit - LearnLearn.co.uk","isPartOf":{"@id":"https:\/\/learnlearn.uk\/microbit\/#website"},"datePublished":"2016-07-06T11:14:49+00:00","dateModified":"2016-07-06T12:57:59+00:00","breadcrumb":{"@id":"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnlearn.uk\/microbit\/2016\/07\/06\/the-friendship-test\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Microbit Unit Home","item":"https:\/\/learnlearn.uk\/microbit\/"},{"@type":"ListItem","position":2,"name":"The Friendship test"}]},{"@type":"WebSite","@id":"https:\/\/learnlearn.uk\/microbit\/#website","url":"https:\/\/learnlearn.uk\/microbit\/","name":"Microbit","description":"Tutorials, Projects &amp; Challenges","publisher":{"@id":"https:\/\/learnlearn.uk\/microbit\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnlearn.uk\/microbit\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/learnlearn.uk\/microbit\/#organization","name":"Microbit","url":"https:\/\/learnlearn.uk\/microbit\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/learnlearn.uk\/microbit\/#\/schema\/logo\/image\/","url":"https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2019\/06\/LearnLearnLogowhite.png","contentUrl":"https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2019\/06\/LearnLearnLogowhite.png","width":710,"height":98,"caption":"Microbit"},"image":{"@id":"https:\/\/learnlearn.uk\/microbit\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/learnlearn.uk\/microbit\/#\/schema\/person\/37d61760b611e12d655e20de44b12f02","name":"learnlearnadmin","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/learnlearn.uk\/microbit\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/07a2ee7e04b8bee91a78709b019de541?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/07a2ee7e04b8bee91a78709b019de541?s=96&d=mm&r=g","caption":"learnlearnadmin"},"url":"https:\/\/learnlearn.uk\/microbit\/author\/learnlearnadmin\/"}]}},"rttpg_featured_image_url":{"full":["https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship.png",439,391,false],"landscape":["https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship.png",439,391,false],"portraits":["https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship.png",439,391,false],"thumbnail":["https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship-150x150.png",150,150,true],"medium":["https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship-300x267.png",300,267,true],"large":["https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship.png",439,391,false],"1536x1536":["https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship.png",439,391,false],"2048x2048":["https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship.png",439,391,false],"neve-blog":["https:\/\/learnlearn.uk\/microbit\/wp-content\/uploads\/sites\/2\/2016\/07\/friendship.png",439,391,false]},"rttpg_author":{"display_name":"learnlearnadmin","author_link":"https:\/\/learnlearn.uk\/microbit\/author\/learnlearnadmin\/"},"rttpg_comment":4,"rttpg_category":"<a href=\"https:\/\/learnlearn.uk\/microbit\/category\/projects\/\" rel=\"category tag\">projects<\/a>","rttpg_excerpt":null,"_links":{"self":[{"href":"https:\/\/learnlearn.uk\/microbit\/wp-json\/wp\/v2\/posts\/603"}],"collection":[{"href":"https:\/\/learnlearn.uk\/microbit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learnlearn.uk\/microbit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/microbit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/microbit\/wp-json\/wp\/v2\/comments?post=603"}],"version-history":[{"count":0,"href":"https:\/\/learnlearn.uk\/microbit\/wp-json\/wp\/v2\/posts\/603\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/microbit\/wp-json\/wp\/v2\/media\/610"}],"wp:attachment":[{"href":"https:\/\/learnlearn.uk\/microbit\/wp-json\/wp\/v2\/media?parent=603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learnlearn.uk\/microbit\/wp-json\/wp\/v2\/categories?post=603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learnlearn.uk\/microbit\/wp-json\/wp\/v2\/tags?post=603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}