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
In this program we will be using Python coding.
You can access the Python Microbit ‘Create Code’ link below.
Micropython Microbit Create CodeClick for code
# This project is designed to test how good a friend you are # by asking you a number of questions about your friend. from microbit import * questions = \ [["Is my favourite colour A - red or B - green?","B"], ["Is my favourite food A - Pizza or B - Spaghetti?","B"], ["Is my cat's name A - Meg or B - Smeg","A"]] score = 0 for question in questions: display.scroll(question[0]) while True: if button_a.is_pressed(): guess = "A" break elif button_b.is_pressed(): guess = "B" break elif accelerometer.was_gesture("shake"): display.scroll(question[0]) sleep(10) if guess == question[1]: display.scroll("Correct...") score += 1 else: display.scroll("Wrong....") display.scroll("Score:" + str(score)) display.scroll("Your friendship score is " + str((score/len(questions))*100) + "%" )