Meditation APP Blog Post (+Review of whole I2P Semester)

Sidenote: (click on pics for a better view!!!)

QUESTIONAIRRE RESULTS:
Are there any important issues with school that you face daily?
19 responses
Yes
No
21.1%
78.9%
Yes 15
No 4
What are they?
19 responses
Bathroom
N/A
Cafeteria Food
toilet
There is plenty of stress from homework, and the biggest problem is that it is sometimes hard to find time to do it without giving up sleep.
Lack of flexibility in learning. When AP classes finish teachers do “filler stuff” instead of allowing us to work on other classes or activities we are passionate about. Teachers do not effectively use class time. Some of them go off task very often. Others give us “work time” but this isn’t a good use of class time. I can do my independent work at home but I can’t teach myself all the important things I would want to here from my teachers.
academics
AP World, Hum, HAA, and Bio
None
Homework
The stress put onto the students with how much education is stressed.
Homework, grades, friends 🙁
Stress
homework
going to school
NA
too much work
Sodexo
n/a
Do you think others also face these problems?
19 responses

Yes84.2%
No15.8%
Yes 16
No 3
How might we help with these issues?
19 responses
Renovation
N/A
Demand better menu and lower prices
clean
Less homework is not an option, but maybe a better managed schedule for homework would help.
Reduce the amount of time students need to spend in class. When we have too much class time, we don’t use every moment effectively. If we reduce this, students would be more concentrated in class and more on task.
mental support
Revise the curriculum to make it so that more students can easier succeed
There are no big issues
More library space for working
Having students help other students understand the necessary priorities in life and that academics aren’t the only important thing in life.
Counselling and choosing right friends
idk lol
less homework
more days off
Na
give less work
Improve the quality of food
idk
Is stress a big part of your school life?
19 responses
Yes78.9%
No21.1%
Yes 15
No 4
What are some ways that you destress?
19 responses
Do what I like to do: gaming, chatting with friends
Sleep
Games
i say no stress and it goes away
I usually play video games or talk to my friends.
I dont.
youtube
Sleep, game
Play tennis
I listen to music, watching youtube, sleeping, and eating.
Meditate and drum
Talking and playing with friends
procrastination
i talk with my friends
not going
League
watch youtube
Play around, Play sports
sing

THis is the link to our survey:
https://docs.google.com/a/hkis.edu.hk/forms/d/1drh7Ro8UrhzLHu5rGVSwm6qMIIoZiWRh361Hu9VGMnQ/prefill

DESIGN THINKING SENTENCE:
To create a Meditation app named “Stargazing” in order to tackle the growing pressure of stress in the everyday life of adults, teenagers, and kids alike.

LIST OF EQUIPMENT NEEDED FOR PROJECT:
• Google Survey
• Android Emulator for Mac
• Android Phone
• MIT App Inventor App
• Personality Quiz but for Meditation (https://www.tryinteract.com/share/quiz/592256b5b477600011655bf8)

FLOWCHART:IMG_20170524_083829

These are three online references I used to get familiar with MIT app inventor as well as troubleshoot my problems:
http://appinventor.mit.edu/explore/sites/all/files/hourofcode/AppInventorTutorials.pdf
https://stackoverflow.com/questions/31027981/maximum-size-limit-restriction-of-mit-app-inventor-project
https://stackoverflow.com/questions/28869954/how-can-i-open-a-web-page-in-app-inventor

Testing Document:Screen Shot 2017-05-31 at 9.35.17 pm

Program Code (The code is really in blocks so we can’t copy and paste it in GITHUB but I will post a picture of all the different types of code for each screen we used.):
Screen Shot 2017-05-31 at 8.59.10 pm
Screen Shot 2017-05-31 at 8.59.14 pm

Screen Shot 2017-05-31 at 8.59.18 pm

Screen Shot 2017-05-31 at 8.59.22 pm

VIDEO of both the app and the works of it:

Evaluation of Project:
I feel like me and Shikaar did a good job on this project given the limited time we had. We were planning something super and extravagant! but sadly we didn’t have enough time to follow through with our idea (will definitely try to make a super cool app outside of school though!).The program was relatively simply, but it took me a while to get used to the blocks as well as all the plug-ins that needed to be inserted to each screen for the app to work, but I think it turned out well in the end! The meditation app was designed for all ages so we hoped that it would be easy for all ages to use! And I am happy to say that I think we fulfilled our goal! THe app is easy to navigate and easy to use!

Review of I2P:
I think this class is amazing!!!! Aside from the award I received, which I can’t deny I am extremely grateful for, I think the biggest thing I took

ARDUINO

THis was an incredibly fun and interesting lesson. It was really amazing to see, once again, the real life result of my code. Being able to create something like a christmas lights melody from mere lines of code was truly extroadinary. What the Arduino machine does, is essentially a circuit of electrical currents, that is connected to something of a mother board. My computer simply activate that mother board every time I tell it to, allowing me to control when and where the lights appear.

MAKEY MAKEY CLINT REQUIREMENTS

The Clients requirements were to create a timer for the balance board that could record how long the person had lasted on the balance board, and record his time for each try.

(Sorry didn’t have pseudocode photo) but I remember that one difference we had is that, especially for scratch is that we utilized the in-computer timer to create the timer, whereas other people just created a new timer (ex: each sec +1 etc.). I feel like our way is much easier, and it helps people learn more about the program and utilising it.
As for my text based program, I had many problems with that. First I was using a program called tkinter, that I was not familiar with, and so I had to learn how to get familiar with that which is pretty challenging to be honest. I overcame these problems by simply testing out different stuff from the internet, and just finding different ways of incorporating it into my code. If I had more time, I definitely would’ve had found a way to add the player name to my results and keep it each time.
(Because I’m creating this after it was due; oops; I only have my final code, so I’ll upload that instead)

WEB RESOURCES:
https://stackoverflow.com/questions/2400262/how-to-create-a-timer-using-tkinter
https://stackoverflow.com/questions/9342757/tkinter-executing-functions-over-time

SCRATCH$MAKEY MAKEY

I began with Scratch my making a really simple program with a moving sprite, mainly because it seemed like an easy way to test out how Scratch works and the logic by which it runs by. I did more research on Scratch and this is what I found, Scratch is a free educational programming language that was developed by the Lifelong Kindergarten Group at the Massachusetts Institute of Technology (MIT) with over 15 million registered users and 22 million shared projects.

In the future I would definitely love to create something like this!!!!!! Anyway, another thing I found out about scratch was that it was extremely simple to use, everything was so easy to understand and just utilize *thumbs up* for that.

This is a pic of the game I used to test out Scratch:
Screen Shot 2017-05-27 at 9.47.13 am
I originally had a lot more code on there, but I think I deleted it, just to make it more clean.

MAKEY MAKEY:
Aaaah, the makey makey was really fun! It was a great real life usage of coding that you could see in action. What I mean by that is, typically results of your code can only be seen through a computer screen, but for me using the makey makey mean that I was able to have the code do things outside of the computer!!! This was incredibly fun and interesting for me. Unfortunately I do not have the footage of what I created the Makey Makey with (other than the balance board), but I can still give my thoughts on it’s usage!!! I think the makey can be used for many different things, its ability to sense electrical currents and activating different things when a circuit is complete allows us to use it as a catalyst for different actions. Like, if this and this touch, and an electrical current is created, than we can create a event that is a result of this and this touching. It’s a really cool idea!!!!

Here are some web references that I used:
https://wiki.scratch.mit.edu/wiki/How_to_Connect_to_the_Physical_World
https://learn.sparkfun.com/tutorials/makey-makey-advanced-guide
http://makeymakey.com/how-to/classic/

Python RE:Birth Adventure Game 7a,b,c

IMG_20170331_132035

(Really Sorry Mrs. Mok can’t seem to find my flowchart!!!!)

Testing Document:
I don’t really need to create a testing document because I only had one problem with my quiz. But it was quite a big problem that took me maybe 20-30 min to solve. The problem was that during my fight scene of my game, for some reason the values of my strength and the Ghoul’s health seemed to reset to its original value each time. As a result, the main character (you) can’t seem to whittle the ghouls health down to 0 and beat the game. I managed to fix this problem my moving my variables to the top of the code and basically globalizing the variable. I also had to change the bottom set up of my god to return to a newly created function, which I set just above the fight scene.

(Instead of Screenshot I just completely copy and pasted my code underneath, ANNOTATIONS ARE IN CAPS)
#accuracy(50,50)
import time

fear = 0
health = 50
accuracy = 0
strength = 50
defense = 0
turn = 1
Ghoul = 800

THIS IS ESSENTIALLY THE SET UP OF MY CODE. AS WELL AS THE ENTIRE STORYLINE. THIS MAKES UP OF THE CHUNK OF MY CODE, UNTIL THE FIGHT SCENE WHICH I OBVIOUSLY HAD TO CODE A BIT DIFFERENTLY. BUT FOR THIS PART, I MERELY CREATED A FEW LINES OF “PRINT” TO PRINT OUT THE STORY LINE AS WELL AS IF AND ELSE STATEMENTS TO CREATE A MULTIPLE ROUTE KIND OF GAME.

def ReBirth():
global fear
global health
global accuracy
global strength
global turn
print(“You open your eyes…..”)
time.sleep(1.75)
print(“The wind is blowing and the sun is shining…..”)
time.sleep(1.5)
print(“‘Beautiful’, you mutter to yourself.”)
time.sleep(1.5)
print(“You stand up. And see two paths ahead.”)
path = int((input(“Left(1) or Right(2): “)))
if path == 1:
print(“You follow the path….”)
time.sleep(1)
print(“Eventually you find yourself in the middle of the woods”)
time.sleep(1.5)
print(“*Rustle Rustle*”)
time.sleep(1)
print(“You freeze….and your frail heart seems to stop beating”)
time.sleep(1)
reaction1 = int(input(“Flee(1) or Investigate(2)”))
if reaction1 == 1:
strength += 30
print()
else:
print(“You wait, ready to fight”)
time.sleep(1)
print(“Oh it’s just a rabbit”)
time.sleep(1)
print(“You continue onwards”)
time.sleep(1)
print(“Eventually you come across a clearing in the woods, there is a pool of water”)
time.sleep(1)
reaction2 = int(input(“Drink(1) or Avoid(2)”))
if reaction2 == 1:
health += 15
time.sleep(1)
print(“Aaaaah, that’s some good water”)
time.sleep(1)
print(“You continue onward”)
time.sleep(1)
else:
time.sleep(0.5)
print(“You avoid the pool, and continue onward”)
time.sleep(1)
print(“The road turns rocky, your feet are getting sore…”)
time.sleep(1.5)
print(“Eventually, you see a mountain range in the distance”)
time.sleep(0.5)
print(“And as the sun shines down on the path…you notice a glimmer on the ground ahead of you”)
time.sleep(1.5)
print(“As you approach the gleam, you make out its figure”)
time.sleep(1)
print(“A beautifully engraved spear lies on the ground”)
time.sleep(1)
reaction3 = int(input(“Pick up Spear(1) or Walk away(2)”))
time.sleep(1)
if reaction3 == 1:
print(“”)
else:
print(“But you can’t walk away, it’s almost calling your name…”)
print(“You pick up the spear, feeling its engraving rub against the palm of your hand”)
time.sleep(0.5)
print(“Slowly, the engravings on the spear travel from the metal to your arm. You look down to read it…”)
time.sleep(0.5)
print(“It says….”)
time.sleep(1)
print(“Suddenly the ground RUMBLES”)
time.sleep(1)
print(“A cloaked figure appears in front of you, you see a gleam of silver under his cloak”)
print(“You sense danger, and raise the spear in defense”)
time.sleep(1)
print(“BATTLE BEGIN”)

OK NOW THIS IS THE FIGHTING SCENE!!!!! I HAVE TO BATTLE AGAINST THE GHOUL. I SIMPLY CREATED TWO VARIABLES MY CHARACTERS STRENGTH AND THE GHOULS HEALTH. AND I REASSIGNED VARIABLES EACH TIME THE USER CLICKS 1, SO THAT THE USER IS GRADUALLY KILLING THE GHOUL.

def fight():
global turn
global Ghoul
Battlechoice1 =int(input(“Attack the Ghoul!!! Press (1)!!!!”))
if Battlechoice1 == 1:
Ghoul -= strength
print(“The Ghoul lost”,strength, “health!!!!”, Ghoul – strength, “health points left”)
turn += 1
else:
print(“You were too frightened to move”)
turn+= 1
print(“AAAAAHHHHH!”)
print(“You lost 30 health”)
if turn != 10:
return fight()
else:
print(“You’re tired, and at your wits end…You strike out one final attack at the ghoul”)

NOW IS THE ENDING OF MY CODE; SAME AS THE BEGINNING JUST MULTIPLE “PRINTS” TO FINISH THE GAME.

time.sleep(1)
print(“As if invigorated by your spirit, your spear emits a shining white light.”)
time.sleep(1)
print(“You feel your spear dig into the flesh of ghoul”)
time.sleep(1)
print(“You pass out from exhaustion”)
time.sleep(1)
print(“When you wake up the sun is up and you’re alive”)
time.sleep(1)
print(“You stand up, and realize you’re on your bed, back at home”)
time.sleep(1)
print(“You wonder if it was just a dream….but shake the memory off your mind and get ready for school”)
time.sleep(1)
print(” The wind is blowing and the sun is shining….., and the words on your arm come into vision under the sunlight”)
print(“It wasn’t a dream”)

fight()

health += -30

#elif path == 2:
# print(“Place holder”)
#else:
# return ReBirth()

ReBirth()

Python Lesson 6a and 6b

This is a small snip-it of Python Lesson 6a:
def f_larger(int1, int2, int3):
print(“Which of these three values is the largest”, int1, int2, int3)
if int1 > int2:
if int1 > int3:
print( int1, “is the largest”)
else:
print( int3, “is the largest”)
elif int2 > int1:
if int2 > int3:
print( int2, “is the largest”)
else:
print( int3, “is the largest”)

f_larger(6,10,8)

What I learned through this lesson can most easily be split into three categories: importance of the function, how functions work, and utilising functions. As you can see above, I placed all my code under the function f_larger, I think the real value in the function, is the ability to really organize your work. To me it’s like writing a paragraph, everything is kind of put underneath your topic sentence, and all of your topic sentences kind of combine to create the whole essay. However, one thing that is vastly different in coding and writing essays, is that with the organization comes a much greater ability to plug in values into the function. This allows you to utilise it as you like, as well as call it up and change the values whenever you want. In regards to the list, I mainly learned how to plug values into the lists easily by simply creating a function with a few variables between the brackets, than later when you call it up you can simply just put numbers inside the brackets. These numbers act as a way to replace the variables thus allowing you to change the values in your function.

6b:

v_price = 0
v_choice = int(input(“Pick a snack you would like, (1) fruit and nut bar, (2) Chocolate Bar, (3) Milk Bar”))
if v_choice == 1:
v_price = v_price+ 34
v_confirm = str(input(“the fruit and nut bar is $34, Would you still like to purchase: “))
if v_confirm == “yes”:
v_paid = int(input(“Please input how much money you would like to pay: “))
v_change = v_paid – v_price
print(“Here is your change: $”, v_change)
elif v_choice == 2:
v_price = v_price + 48
v_confirm = str(input(“the Chocolate bar is $48, would you still like to purchase: “))
if v_confirm == “yes”:
v_paid = int(input(“Please input how much money you would like to pay: “))
v_change = v_paid – v_price
print(“Here is your change: $”, v_change)
elif v_choice == 3:
v_price = v_price + 52
v_confirm = str(input(“the Chocolate bar is $52, would you still like to purchase: “))
if v_confirm == “yes”:
v_paid = int(input(“Please input how much money you would like to pay: “))
v_change = v_paid – v_price
print(“Here is your change: $”, v_change)

v_price = 0
v_choice = int(input(“Pick a snack you would like, (1) fruit and nut bar, (2) Chocolate Bar, (3) Milk Bar”))
if v_choice == 1:
v_price = v_price+ 34
v_confirm = str(input(“the fruit and nut bar is $34, Would you still like to purchase: “))
if v_confirm == “yes”:
v_paid = int(input(“Please input how much money you would like to pay: “))
v_change = v_paid – v_price
print(“Here is your change: $”, v_change)
elif v_choice == 2:
v_price = v_price + 48
v_confirm = str(input(“the Chocolate bar is $48, would you still like to purchase: “))
if v_confirm == “yes”:
v_paid = int(input(“Please input how much money you would like to pay: “))
v_change = v_paid – v_price
print(“Here is your change: $”, v_change)
elif v_choice == 3:
v_price = v_price + 52
v_confirm = str(input(“the Chocolate bar is $52, would you still like to purchase: “))
if v_confirm == “yes”:
v_paid = int(input(“Please input how much money you would like to pay: “))
v_change = v_paid – v_price
print(“Here is your change: $”, v_change)

v_price = 0
v_choice = int(input(“Pick a snack you would like, (1) fruit and nut bar, (2) Chocolate Bar, (3) Milk Bar”))
if v_choice == 1:
v_price = v_price+ 34
v_confirm = str(input(“the fruit and nut bar is $34, Would you still like to purchase: “))
if v_confirm == “yes”:
v_paid = int(input(“Please input how much money you would like to pay: “))
v_change = v_paid – v_price
print(“Here is your change: $”, v_change)
elif v_choice == 2:
v_price = v_price + 48
v_confirm = str(input(“the Chocolate bar is $48, would you still like to purchase: “))
if v_confirm == “yes”:
v_paid = int(input(“Please input how much money you would like to pay: “))
v_change = v_paid – v_price
print(“Here is your change: $”, v_change)
elif v_choice == 3:
v_price = v_price + 52
v_confirm = str(input(“the Chocolate bar is $52, would you still like to purchase: “))
if v_confirm == “yes”:
v_paid = int(input(“Please input how much money you would like to pay: “))
v_change = v_paid – v_price
print(“Here is your change: $”, v_change)”””

def f_change():
v_paid = float(input(“Please input how much money you would like to pay: “))
if v_paid >= v_price:
v_change = v_paid – v_price
print(“Here is your change: $”, v_change)
v_20 = int(v_change/20)
v_10 = int((v_change%20)/10)
v_5 = int(((v_change%20)%10)/5)
v_1 = int((((v_change%20)%10)%5)/1)
print(“In other words, “, v_20,”$20s”, v_10,”$10s”, v_5,”$5s”, v_1, “$1s”)

else:
print(“Sorry bud not enough $$$, you need $”, v_price – v_paid, “more, try again”)
return f_change()

v_price = 0
v_choice = int(input(“Pick a snack you would like, (1) fruit and nut bar, (2) Chocolate Bar, (3) Milk Bar”))
if v_choice == 1:
v_price = v_price+ 34
v_confirm = str(input(“The fruit and nut bar is $34, Would you still like to purchase: “))
if v_confirm == “yes”:
f_change()

else:
print(“alright get out of my system and rerun”)
elif v_choice == 2:
v_price = v_price + 48
v_confirm = str(input(“The Chocolate bar is $48, would you still like to purchase: “))
if v_confirm == “yes”:
f_change()
else:
print(“alright get out of my system and rerun”)
elif v_choice == 3:
v_price = v_price + 52
v_confirm = str(input(“The Milk bar is $52, would you still like to purchase: “))
if v_confirm == “yes”:
f_change()

else:
print(“alright get out of my system and rerun”)

OK, after reading that super duper long lines of code, heres the basic run down of what I did. I created a flowchart to create a general idea of what I wanted my code to do. Then I created my code. Haha, it seems pretty simple, but that is essentially all I did. My code is quite a messy repetition of if and else statements over and over again, I think I could change that maybe using the method from my previous lesson, in which I could exchange all the values again by simply setting new values to the same variable each time. I’ll probably try that in the future. Also, the hardest part of my code was probably the price calculation part, that takes quite a few minutes to figure out how to do, but overall it was a really fun experience and can’t wait to create something more similar and more efficient than this!!!

(S) Makey Makey Board Py

SCRATCH VIDEO

Tkinter Video

Testing Documents:
To be completely honest Scratch didn’t require any testing documents at all, and I think the same can be said for most of my classmates as well, it was a relatively straightforward program that didn’t require much debugging or testing. Tkinter however, haha, I think I made about 6 different testing documents for that one. Although I won’t post all of them on my blog right now, I’ll explain a bit and go through each one.

1st:
The first testing document was actually created by Mr. Lin. The main problem at the time was that for some reason I couldn’t import Tkinter, despite having downloaded it properly and everything. In the end, we realized that the problem was that my file was named tkinter.py, which just so happened to be the name of the tkinter file library in Pycharm. As such every time I tried to import tkinter, it would automatically redirect to the file library, thus I couldn’t extract anything. So the first testing document we made was to test our theory, and sure enough it worked.

2nd:
The second testing document I created was one to simply understand the stopwatch program lines of code that I found online better. For this testing document, I simply changed values of all the lines of code in the program that I didn’t understand, I would then run the program and see what changed, thus I was able to assign each line of code to their function in the GUI. Relatively simply testing document.

3rd: The 3rd Testing Document was one that I used to help me with my new found key link solution that I had discovered online. I used this testing document to simply mess around with the lines of code that I copied from online, once again to find out what each part did, and as such was able to have a general gist how and where I should put it into my stopwatch code.
Here is the Code:
def leftKey(event):
print (“Left key pressed”)

def rightKey(event):
print (“Right key pressed”)

frame = Frame(root, width=100, height=100)
frame.bind(‘‘, leftKey)
frame.bind(‘‘, rightKey)
frame.focus_set()
frame.pack()
root.mainloop()

4th:
My 4th Testing Document was used to integrate the above lines of code into my Stopwatch code. In order to do so, I simply copy and paste it in, then began eliminating all the bugs that began to show up. I think I spent the most time on this testing document overall because every time I would integrate the keybind code into the program I would solve all the bugs only to find one problem that resulted due to the actual placement of the code in the stopwatch program. As such I would have to move my keybind code to another destination, and then once again solve all the bugs. This repeated maybe 3 times before I finally was able to integrate successfully without any bugs whatsoever. Some problems that came up were simply, having to import “Frame”, as well as unifying all the lines of code under a single variable of
“root = Tk()”.

5th: My 5th Testing Document was created to once again test and tweak with a new Listbox line of code for my program, I was gonna use it to hold all the player records and their scores on the Balance Board. I actually had to sort of mix to different solutions I found online in order to create a list box that worked on my testing document, I’m not sure why but it is probably a result of having different programs or simply different downloaded packages. Whatever the case I eventually was able to find a listbox line of code that actually worked.
Line of Code:
listbox = Listbox(root, height=3,width=10)
listbox.insert(1, self._elapsedtime)

listbox.pack()
root.mainloop()
6th: Finally, my last testing document was used to completely integrate the list. Into my program, this was a lot easier I got it on about my second try, but the bugs that came up were relatively easy to solve and eliminate. So I was able to fully integrate my list box in the end, however, I didn’t have much time to find a way to add in the Name of the User or Rankings, rather I simply had a table that recorded down how long each person lasted on the balance board (in seconds).

Some of the Websites I used were:
http://code.activestate.com/recipes/124894-stopwatch-in-tkinter/
(This is where I got my stopwatch line of code)

http://stackoverflow.com/questions/19895877/tkinter-cant-bind-arrow-key-events
(used to find how to bind Arrow keys)

http://effbot.org/tkinterbook/listbox.htm
http://stackoverflow.com/questions/15705745/how-to-fit-tkinter-listbox-to-contents
(Used to find how to add in listbox into my Stopwatch Code)

April 27, 2017

I used my research online in order to find a method to incorporate the timer into a GUI. I used this code

import pygame
import tkinter
import time
from pygame.locals import *

# set up pygame
pygame.init()

# set up the window
windowSurface = pygame.display.set_mode((500, 400), 0, 32)
pygame.display.set_caption(‘Hello world!’)

class StopWatch(tkinter.Frame):

@classmethod
def main(cls):
tkinter.NoDefaultRoot()
root = tkinter.Tk()
root.title(‘Stop Watch’)
root.resizable(True, False)
root.grid_columnconfigure(0, weight=1)
padding = dict(padx=5, pady=5)
widget = StopWatch(root, **padding)
widget.grid(sticky=tkinter.NSEW, **padding)
root.mainloop()

def __init__(self, master=None, cnf={}, **kw):
padding = dict(padx=kw.pop(‘padx’, 5), pady=kw.pop(‘pady’, 5))
super().__init__(master, cnf, **kw)
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(1, weight=1)
self.__total = 0
self.__label = tkinter.Label(self, text=’Total Time:’)
self.__time = tkinter.StringVar(self, ‘0.000000’)
self.__display = tkinter.Label(self, textvariable=self.__time)
self.__button = tkinter.Button(self, text=’Start’, command=self.__click)
self.__label.grid(row=0, column=0, sticky=tkinter.E, **padding)
self.__display.grid(row=0, column=1, sticky=tkinter.EW, **padding)
self.__button.grid(row=1, column=0, columnspan=2,
sticky=tkinter.NSEW, **padding)

def __click(self):
if self.__button[‘text’] == ‘Start’:
self.__button[‘text’] = ‘Stop’
self.__start = time.clock()
self.__counter = self.after_idle(self.__update)
else:
self.__button[‘text’] = ‘Start’
self.after_cancel(self.__counter)

def __update(self):
now = time.clock()
diff = now – self.__start
self.__start = now
self.__total += diff
self.__time.set(‘{:.6f}’.format(self.__total))
self.__counter = self.after_idle(self.__update)

if __name__ == ‘__main__’:
StopWatch.main()

Still trying to incorporate it in, because so far all it does is crash Python. I feel like there’s some potential in this code so I will continue to find a way to incorporate it into GUI. I’ve also been working on the Pycharm version of the Balance Board, and so far I’ve been pretty successful with that. However, in regards to this code, it counts up. And my hope is that it will be able to record the user name and time.

I2P Summative (Quiz)

EmbeddedFlowChart (mini flowchart representing how I wanted my quiz question to be formatted)17841797_441861239491882_835341664_n

Game:

My Game is called the HKIS STUDENT VOCAB TEST, mainly because it is a vocab test geared to ask HKIS students to define words that they should know as HKIS students. Or for non-HKIS students, just letting them know what kind of words HKIS teachers teach students.

It works by the computer being programmed to randomly choose a word from a list, and the user is given multiple choices to answer that question. If they get it right, then they move on to the next word. If they get it wrong a certain amount of times, then the program kicks them out of the system essentially.

At the end of the test the computer will show the user how many questions he got wrong, what percentage of the questions did he get correct. And the game ends.

Documentation (What worked what didn’t)
I didn’t have any particular problem with the actual program other than the main issue that I was stuck on for a couple of hours, being able to arrange new values for a variable through randomization. For some reason, even after I set a new value for my random variable, it still kept on using the same variable as it has before. In order to solve this, I had to add a new function that random-ified the variable and constantly switch back to that function. Other than that, all the issues I had were minor, missing parentheses, missing letter, functions not in order etc. (MORE WILL BE BELOW IN THE STEP BY STEP RUN-THROUGH)

STEP BY STEP RUN DOWN of each section of code:
PART#1:
import random
import sys
words = [“Python”, “Chocolate”, “China”, “King”, “Vegan”,”Hammer”,”Penguin”,”Basketball”,”Temple”,”Mexican”]
cwords = [“美国”, “中国”, “日本”, “巴西”, “英国”, “法国”]
RandomW = random.choice(words)
cRandomW = random.choice(cwords)
counter = 0
tries = 0
ctries = 0
ccounter = 0
V_name = input(“Please Enter Your Name: “)
print(“This quiz will be testing you on your HKIS vocabulary bank today!”)

print(“The computer will begin selecting different words for you to choose from, and define!”)

print(“Here is your first word”, RandomW)

This is the setting up of my whole code, basically I set up all the imports, created the lists for my words and chinese words (to use to ask questions later), set up all the variables such as the RandomW which is the the random word the code will pick to ask each time, as well as the counter and timer for the last piece of my code. After, it also contains the beginning introductions of the code, as in the, “Hello what’s your name, and the instructions. These are all basic necessities for my code to run, can’t really see a way to simplify or improve this any further.
PART#2
def question():
global RandomW
global words
print(“What does this word mean?”)
RandomW = random.choice(words)
print(RandomW)
choice()
def choice():
global counter
global RandomW
global tries
global words
vocab_1meaning = int(input(“”” (1) A large Snake,
(2)A delicious sweet treat that people love to eat ,
(3) A beautiful country in the Eastern Hemisphere of the world,
(4) A Monarch,
(5) Someone who only has made the decision to not eat meat.
(6) Steel tool used to hit things,
(7) A bird that cannot fly, and lives in cold places,
(8) Something your supposed to shoot through a hoop with,
(9) Somewhere buddhist pray,
(10) Someone from Mexico”””))
if RandomW == “Python”:
print(“OK, your definition is……….”)
if vocab_1meaning== 1:
print(“CORRECT!!!!!”)
words.remove(“Python”)
counter +=1
tries +=1
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG! Please try again”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()

The function “choice” that I wrote above is the function that contains the coding for my question and answer system. Firstly, you can see the multiple choice option called up above that the user can choose form, the user will then need to pick a number 1-10 in correspondence to what they believe the definition of the word is I have only extracted a part of the function and pasted it on top, in reality, the “Choice” function contains the code for what would happen depending on what word my RandomW variable calls up first from my words list. As you can see above, I have extracted the coding for if the RandomW variable = Python, I did the same thing for all the other words that can be randomly extracted from my words list. I also used the same method for my bonus round Chinese vocab quiz close to the end of the program as well. This METHOD is me basically using a lot of if and else statements as well as nested if and else statements within them as well. The majority of my code is basically all in this structure but for the different random choices taken from my lists. I also added in all of the +1 to my tries and counters variable, which will be used later on to determine how well they did on each quiz.
The function “question” above that was a solution to a problem I encountered while writing this part of my code. The problem was that each time I asked the random generator to pull a new random word, it would just use the same word as before. As a result, I made a simple second function that pulled a new random word from the lists, and had the function “choice” go to this new function “question” in order to pull a truly random word. Sure enough it worked

PART#3
def ending():
print(“But before we end…..Time for the bonus round!!!!!”)
print(“As a student of HKIS your chinese must be up to proficiency as well!!!”)
global cRandomW
global cwords
print(“What country do these chinese characters represent?”)
cRandomW = random.choice(cwords)
print(cRandomW)
cgame()
def cquestion():
global cRandomW
global cwords
import random
print(“What does country do these Chinese Characters represent”)
cRandomW = random.choice(cwords)
print(cRandomW)
cgame()
def cgame():
global cRandomW
global ctries
global ccounter
global cwords
cvocab_1meaning = int(input(“””
(1)America
(2)China
(3)Japan
(4)Brazil
(5)Great Britain
(6)France
“””))

These lines of codes are set ups lines for my bonus Chinese Vocab rounds. It’s basically a few lines of code introducing what I’m going to do next (have them translate Chinese words for Countries around the world), as well as setting up my random word generator for my Chinese word list. Also, the multiple answer choices the author can choose from. After this, I basically repeated my if and else statement method is shown in PART#2, except I changed all the necessary variables to apply it to my Chinese vocab bonus round questions and answers.

PART#4
def final():
global tries
global ctries
print(“Congratulations! I offer my utmost respect for an intellectual such as you for completing this quiz”)
print(“You have managed to finish this quiz with,”, tries ,”tries in the Main quiz and “,tries-10,”wrong guesses, that is about,”, ((tries-10)/10)*100,”%”)
print(“As for the bonus quiz, You have managed to finish it with,”, ctries,”tries in the Bonus quiz and”,ctries-6,”wrong guesses, that is about,”, ((ctries-6)/6)*100,”%”)

This is the final part of my quiz, it tells you how well you did on your quiz. I did this by first telling the user how many tries it took him to get all the questions, as well as how many wrong guesses (tries-guesses), and then finally what percent he got correct ((tries-total number of questions)/(total number of questions)). This gives the user a more easily understandable way to read how well he did

TESTING DOCUMENT:
Screen Shot 2017-04-19 at 1.51.05 pm

Websites:
A few websites that I used to figure out some issues.
http://stackoverflow.com/questions/73663/terminating-a-python-script
http://www.dummies.com/programming/python/how-to-modify-lists-in-python/
http://stackoverflow.com/questions/29701437/globalising-variables-from-sub-routine-into-another-sub-routine
*I mainly used my notes from previous lessons

#TITLE: THE HKIS STUDENT VOCAB TEST

#HOW TO PLAY:
# You will be given a few words,
#and you shall define the meaning of the words that you are given using multiple choice answers.
# In order to answer, put the number in accordance to your answer.
#For Example: If it asks you to define “sharks”, and one of the choices is (3)a small animal from the sea which has fins and sharp teeth
#Then you would enter “3” as your answer
#That’s it have fun, and I hope you learn a lot
import random
import sys
words = [“Python”, “Chocolate”, “China”, “King”, “Vegan”,”Hammer”,”Penguin”,”Basketball”,”Temple”,”Mexican”]
cwords = [“美国”, “中国”, “日本”, “巴西”, “英国”, “法国”]
RandomW = random.choice(words)
cRandomW = random.choice(cwords)
counter = 0
tries = 0
ctries = 0
ccounter = 0
V_name = input(“Please Enter Your Name: “)
print(“This quiz will be testing you on your HKIS vocabulary bank today!”)

print(“The computer will begin selecting different words for you to choose from, and define!”)

print(“Here is your first word”, RandomW)

def question():
global RandomW
global words
print(“What does this word mean?”)
RandomW = random.choice(words)
print(RandomW)
choice()
def choice():
global counter
global RandomW
global tries
global words
vocab_1meaning = int(input(“”” (1) A large Snake,
(2)A delicious sweet treat that people love to eat ,
(3) A beautiful country in the Eastern Hemisphere of the world,
(4) A Monarch,
(5) Someone who only has made the decision to not eat meat.
(6) Steel tool used to hit things,
(7) A bird that cannot fly, and lives in cold places,
(8) Something your supposed to shoot through a hoop with,
(9) Somewhere buddhist pray,
(10) Someone from Mexico”””))
if RandomW == “Python”:
print(“OK, your definition is……….”)
if vocab_1meaning== 1:
print(“CORRECT!!!!!”)
words.remove(“Python”)
counter +=1
tries +=1
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG! Please try again”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()
elif RandomW == “Chocolate”:
print(“OK, your definition is……….”)
if vocab_1meaning== 2:
print(“CORRECT!!!!!”)
words.remove(“Chocolate”)
counter +=1
tries +=1
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG!”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()
elif RandomW == “China”:
print(“OK, your definition is……….”)
if vocab_1meaning== 3:
print(“CORRECT!!!!!”)
counter += 1
tries += 1
words.remove(“China”)
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG! Please try again”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()
elif RandomW == “King”:
print(“OK, your definition is……….”)
if vocab_1meaning== 4:
print(“CORRECT!!!!!”)
counter +=1
tries += 1
words.remove(“King”)
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG! Please try again”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()
elif RandomW == “Vegan”:
print(“OK, your definition is……….”)
if vocab_1meaning== 5:
print(“CORRECT!!!!!”)
counter += 1
tries += 1
words.remove(“Vegan”)
print(“Lets try a New Word”)
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG! Please try again”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()
elif RandomW == “Hammer”:
print(“OK, your definition is……….”)
if vocab_1meaning== 6:
print(“CORRECT!!!!!”)
words.remove(“Hammer”)
counter +=1
tries +=1
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG! Please try again”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()
elif RandomW == “Penguin”:
print(“OK, your definition is……….”)
if vocab_1meaning== 7:
print(“CORRECT!!!!!”)
words.remove(“Penguin”)
counter +=1
tries +=1
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG! Please try again”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()
elif RandomW == “Basketball”:
print(“OK, your definition is……….”)
if vocab_1meaning== 8:
print(“CORRECT!!!!!”)
words.remove(“Basketball”)
counter +=1
tries +=1
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG! PLease try again”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()
elif RandomW == “Temple”:
print(“OK, your definition is……….”)
if vocab_1meaning== 9:
print(“CORRECT!!!!!”)
words.remove(“Temple”)
counter +=1
tries +=1
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG!”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()
elif RandomW == “Mexican”:
print(“OK, your definition is……….”)
if vocab_1meaning== 10:
print(“CORRECT!!!!!”)
words.remove(“Mexican”)
counter +=1
tries +=1
if counter == 10:
print(“Yay, you’ve finished all the words!!!!”)
print(“You’ve managed to accomplish this in”,tries,”tries!” )
ending()
else:
print(“Time for the next word!”)
return question()
else:
print(“WROONG! Please try again”)
tries +=1
if tries > 20:
print(“I’m sorry you’ve failed the program, please try again in a day”)
sys.exit()
else:
return choice()

def ending():
print(“But before we end…..Time for the bonus round!!!!!”)
print(“As a student of HKIS your chinese must be up to proficiency as well!!!”)
global cRandomW
global cwords
print(“What country do these chinese characters represent?”)
cRandomW = random.choice(cwords)
print(cRandomW)
cgame()
def cquestion():
global cRandomW
global cwords
import random
print(“What does country do these Chinese Characters represent”)
cRandomW = random.choice(cwords)
print(cRandomW)
cgame()
def cgame():
global cRandomW
global ctries
global ccounter
global cwords
cvocab_1meaning = int(input(“””
(1)America
(2)China
(3)Japan
(4)Brazil
(5)Great Britain
(6)France
“””))
if cRandomW == “美国”:
print(“OK, your definition is……….”)
if cvocab_1meaning== 1:
print(“CORRECT!!!!!”)
cwords.remove(“美国”)
ctries +=1
ccounter += 1
if ccounter == 6:
print(“Yay, you’ve finished the bonus round!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
final()
else:
print(“Time for the next word!”)
return cquestion()
else:
print(“WROONG! Please try again”)
ctries +=1
return cgame()
if cRandomW == “中国”:
print(“OK, your definition is……….”)
if cvocab_1meaning== 2:
print(“CORRECT!!!!!”)
cwords.remove(“中国”)
ctries +=1
ccounter += 1
if ccounter == 6:
print(“Yay, you’ve finished the bonus round!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
final()
else:
print(“Time for the next word!”)
return cquestion()
else:
print(“WROONG! Please try again”)
ctries +=1
return cgame()
elif cRandomW == “日本”:
print(“OK, your definition is……….”)
if cvocab_1meaning== 3:
print(“CORRECT!!!!!”)
cwords.remove(“日本”)
ctries +=1
ccounter += 1
if ccounter == 6:
print(“Yay, you’ve finished the bonus round!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
final()
else:
print(“Time for the next word!”)
return cquestion()
else:
print(“WROONG! Please try again”)
ctries +=1
return cgame()
elif cRandomW == “巴西”:
print(“OK, your definition is……….”)
if cvocab_1meaning== 4:
print(“CORRECT!!!!!”)
cwords.remove(“巴西”)
ctries +=1
ccounter += 1
if ccounter == 6:
print(“Yay, you’ve finished the bonus round!!!!”)
print(“You’ve managed to accomplish this in”,tries,”times!” )
final()
else:
print(“Time for the next word!”)
return cquestion()
else:
print(“WROONG! Please try again”)
ctries +=1
return cgame()
elif cRandomW == “英国”:
print(“OK, your definition is……….”)
if cvocab_1meaning== 5:
print(“CORRECT!!!!!”)
cwords.remove(“英国”)
ctries +=1
ccounter += 1
if ccounter == 6:
print(“Yay, you’ve finished the bonus round!!!!”)
print(“You’ve managed to accomplish this in”,ctries,”times!” )
final()
else:
print(“Time for the next word!”)
ctries +=1
return cquestion()
else:
print(“WROONG! Please try again”)
ctries +=1
return cgame()
elif cRandomW == “法国”:
print(“OK, your definition is……….”)
if cvocab_1meaning== 6:
print(“CORRECT!!!!!”)
cwords.remove(“法国”)
ctries +=1
ccounter += 1
if ccounter == 6:
print(“Yay, you’ve finished the bonus round!!!!”)
print(“You’ve managed to accomplish this in”,ctries,”times!” )
final()
else:
print(“Time for the next word!”)
return cquestion()
else:
print(“WROONG! Please try again”)
ctries +=1
return cgame()
def final():
global tries
global ctries
print(“Congratulations! I offer my utmost respect for an intellectual such as you for completing this quiz”)
print(“You have managed to finish this quiz with,”, tries ,”tries in the Main quiz and “,tries-10,”wrong guesses, that is about,”, ((tries-10)/10)*100,”%”)
print(“As for the bonus quiz, You have managed to finish it with,”, ctries,”tries in the Bonus quiz and”,ctries-6,”wrong guesses, that is about,”, ((ctries-6)/6)*100,”%”)

choice()

Lesson 5 I2P

Today we worked on a new adaptation to the guess the number game, and created the Guess the Word game. It is definitely a lot harder simply because of the nature of the game, a word is made up of many letters and we had to find a way to make the computer identify each letter in the word and be able to guess each letter in each try. However, it was still really fun to work on. Today I didn’t really learn much rather than solidified my understanding. With the Guess the Word problem, I managed to practice my use of the Def function, as well as running the game and returning back to the game. Screen Shot 2017-03-26 at 9.42.17 am

Screen Shot 2017-03-26 at 9.42.19 am

Screen Shot 2017-03-26 at 9.42.21 am