Skip to content

Instantly share code, notes, and snippets.

@Mr-Coxall
Last active July 1, 2018 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mr-Coxall/1035f2e9b605db7988614d1bcbf7c8da to your computer and use it in GitHub Desktop.
Save Mr-Coxall/1035f2e9b605db7988614d1bcbf7c8da to your computer and use it in GitHub Desktop.
area_and_perimeter.py
# Created by: Mr. Coxall
# Created on: Sep 2018
# Created for: ICS3U
# This program calculates the area and perimter of a rectangle
import ui
def answer_touch_up_inside(sender):
# displays the answer for area and perimeter
view['area_answer_label'].text = 'Area = ' + str(3*5) + ' cm^2'
view['perimeter_answer_label'].text = 'Perimeter = ' + str(2*(5+3)) + ' cm'
view = ui.load_view()
view.present('full_screen')
[
{
"selected" : false,
"frame" : "{{0, 0}, {1024, 768}}",
"class" : "View",
"nodes" : [
{
"selected" : false,
"frame" : "{{30, 33}, {447, 59}}",
"class" : "Label",
"nodes" : [
],
"attributes" : {
"font_name" : "<System>",
"frame" : "{{437, 368}, {150, 32}}",
"uuid" : "402DB833-686F-4BDF-A3EE-B1EA2077967E",
"class" : "Label",
"alignment" : "left",
"text" : "What is the area and perimeter of a rectangle with length 5 cm and width 3 cm?",
"name" : "instructions_label",
"font_size" : 18
}
},
{
"selected" : false,
"frame" : "{{197, 112}, {80, 32}}",
"class" : "Button",
"nodes" : [
],
"attributes" : {
"action" : "answer_touch_up_inside",
"frame" : "{{472, 368}, {80, 32}}",
"title" : "Answer",
"uuid" : "2B8E6C92-B574-4C48-9177-9874A61C9864",
"class" : "Button",
"name" : "answer_button",
"font_size" : 15
}
},
{
"selected" : true,
"frame" : "{{30, 161}, {150, 32}}",
"class" : "Label",
"nodes" : [
],
"attributes" : {
"font_name" : "<System>",
"frame" : "{{437, 368}, {150, 32}}",
"uuid" : "60474C48-997B-4863-98E4-D6BAA5BC9B4F",
"class" : "Label",
"alignment" : "left",
"text" : "Area =",
"name" : "area_answer_label",
"font_size" : 18
}
},
{
"selected" : false,
"frame" : "{{30, 210}, {150, 32}}",
"class" : "Label",
"nodes" : [
],
"attributes" : {
"font_name" : "<System>",
"frame" : "{{437, 368}, {150, 32}}",
"uuid" : "E66CF93F-FFB1-4070-865D-238F5B92A520",
"class" : "Label",
"alignment" : "left",
"text" : "Perimeter = ",
"name" : "perimeter_answer_label",
"font_size" : 18
}
}
],
"attributes" : {
"enabled" : true,
"background_color" : "RGBA(1.000000,1.000000,1.000000,1.000000)",
"tint_color" : "RGBA(0.000000,0.478000,1.000000,1.000000)",
"border_color" : "RGBA(0.000000,0.000000,0.000000,1.000000)",
"flex" : ""
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment