Skip to content » Microbit Unit Home » The Friendship test

The Friendship test

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 Code
Click 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:
    while True:
        if button_a.is_pressed():
            guess = "A"
        elif button_b.is_pressed():
            guess = "B"
        elif accelerometer.was_gesture("shake"):
    if guess == question[1]:
        score += 1
    display.scroll("Score:" + str(score))

display.scroll("Your friendship score is " + str((score/len(questions))*100) + "%" )