APCSP Final App

Diary of my progress:

Tuesday, May 15: Today I made a questionnaire and asked students for responses during class. It took me about 40 minutes to create the questionnaire, 20 minutes to ask people for responses, and an additional 20 minutes to go through the responses and come up with ideas. That brought me to the end of class.

Thursday, May 17: I realised that I was supposed to have an adult client and gather feedback through questionnaires, so whatever I did last class was wasted. This class I contacted my client, created the questionnaire and sent it out to peers and teachers.

Questionnaire Link: https://docs.google.com/forms/d/1TgJpt6yQMyLvMI1sL5NPOtzrTZNXvRSdOVIlsJDRtVU/edit

Monday, May 21: This class I looked at the responses I received and I wrote down all the functions of the app as well as what the GUI needed and created an abstract flowchart of my app. I took some time downloading music for the app. I also began working on the code. Marcus helped me with coding the sound part by sending me the link to a video showing how to play sound. I was able to code up to the user being able to select the folder where the music is.

Client’s needs:

– Music app to help user sleep

– Tips for falling asleep

– Meditation part of the app

GUI needs:

– Menu to select Music, Sleeping Tips or Meditation

– Sleeping tips needs to be colorful

– Music needs to give the name of the song

– Meditation part needs to be just sound

Flowchart: *Note: I decided to not implement the stoppage of music after 30 minutes as I realised that it was quite pointless seeing that the user can pause the music themselves.

Thursday, May 24: Today I realised that the mp3 files that I had downloaded didn’t work in PyCharm, and I found out that only wav files worked because Marcus informed me, so I had to spend some time converting all of those files into wav files in order for them to play. By the end of class I was only able to play a song, but I had no GUI, or any other functionality.

Friday, May 25: I spent about 5-6 hours coding today. I was able to finish creating the GUI, sleeping tips, and add more functionality to the music player. I was able to add pause and play buttons as well as give the user the title of the song. I spent about 3 hours of that time trying to figure out how to play music one after another. I still need to add some colour to the GUI and style it a bit. As of now, the user still needs to select a folder to play the music, so I want to code the app so that the music automatically starts playing without the user having to select the folder.

Saturday, May 26: Today I finished adding the sleep meditation functionality, so that the audio plays as soon as the button is clicked. After that I went back to my music player to figure out how to get the music to play automatically, which I did figure out. I added colour to the GUI and styled some text. I finished my app and made the video. I also filmed and edited the video interview with client.

Testing Documentation:

Tester’s name Procedure tested Outcome Fixed?
Karan Goel menu() Shows buttons and welcome message No need
Sudhir Goel (Dad) musicchoose() Changes to the music menu, allows user to select folder with music, then plays song.

Removed the choosing of folders to make it automatic by deleting askdirectory(), and instead setting the directory of the music to the path of the folder.

Fixed on May 26

Karan Goel sleepingtips() Prints a sleeping tip and will generate another one if “Another Tip” button is pressed. No need
Sudhir Goel (Dad) pause() Music pauses temporarily No need
Sudhir Goel (Dad) play() Music continues playing from the same location that it was paused No need
Karan Goel sleepmeditation() Allows user to select the folder for sleep meditation and plays track

Removed the choosing of folders to make it automatic and sleeping meditation audio plays.

Fixed on May 26

Karan Goel backtomenu() Goes back to the menu. GUI from sleeping tips is visible.

Added deletemenu() to the function

Fixed May 26

Sudhir Goel (Dad) backtothemenu() Goes back to the menu but GUI is visible and music is still playing

Added deletemenu() to function and added pygame.mixer.music.stop() to stop the music.

Fixed May 26

Karan Goel deletemenu() Blank labels  successfully cover buttons and labels from menu No need

App Video: 


Client Interview: 

Code: https://docs.google.com/document/d/1RoV4QcIC7v3RsaTlmgjDrc17FLWG6rTnrSav8j7VZXk/edit?usp=sharing

Karan Goel Create Task Pun Generator

  1. a. For my create task, I chose to create a random joke generator. I chose to use Python’s Tkinter for the creation of the Graphical User Interface. The purpose of my code is to have a list containing jokes, then to be able to pick one out at random and print it, then to allow the user to input a joke of their own and write that joke onto the preexisting list. My video shows the working program. It contains a label welcoming the user to the generator and has a button to show the joke. When the button is pressed, a random joke is selected, and displayed as a label. The user is then prompted to enter their own joke. After the user enters his/her joke, they press the add joke button to exit the window.

2b. The first point of difficulty that I faced was when I was adding the addJoke button. I was having difficulties with this      because one of the variables, enter, was needed for the command of the button, but I couldn’t figure out how to put it in every if statement and the button command without it showing up twice. In the end, I realized I could put the user entry part of the code into a function and use that function for every if statement. I then made the variable a global variable so I could use it in the command function of the button.

My second point of difficulty was when I needed to find out a way to write the user input into the list of jokes I already made. I searched the internet for hours, trying everything I came across, but none of them worked for some reason, so I still haven’t solved it.


The algorithm pictured above is the most important algorithm in my code because this is the algorithm that prints out the joke and gets the user input. The jokeInput algorithm tells the code to create a label asking the user to input a joke, and then creating a global variable called enter. Then I defined enter as the user entry and placed it at coordinates (0,170). My addJoke function uses the variable i to define the position that the entry should be in, and then exits the code. The addJoke function is the command for the Add joke button, and the jokeInput function is to have more efficient code.


This part of my code contains two functions that are both critical abstractions.The first one jokeInput, is a function that allows the user to input their own joke. This helps makes my code simpler because I just used one function instead of writing the same code over 4 times. The second piece of code contains the mathematics. In addJoke, I insert the user’s input into the list of jokes. By using i + 1, I am able to get the program to insert the input one to the right of the list everytime an input is made. I used a starting point of three because that is the position of the last joke in the list. From here it adds one every time, and inserts the input.

3. Important Algorithm: 


Insertion Sort and Binary Search


Insertion Sort Code:

import time
def insertionSort(arr):
    # Traverse through 1 to len(arr)
    for i in range(1, len(arr)):
        key = arr[i]
        # Move elements of arr[0..i-1], that are
        # greater than key, to one position ahead
        # of their current position
        j = i-1
        while j >=0 and key < arr[j] :
                arr[j+1] = arr[j]
                j -= 1
        arr[j+1] = key
# Driver code to test above
a = int(input("Enter a number:"))
b = int(input("Enter a number:"))
c = int(input("Enter a number:"))
d = int(input("Enter a number:"))
e = int(input("Enter a number:"))

arr = [a, b, c, d, e]
print ("Sorted array is:")

Binary search code:
def binary_search(array, target):
    lower = 0
    upper = len(array)
    while lower < upper:   # use < instead of <=
        x = lower + (upper - lower) // 2
        val = array[x]
        if target == val:
            print("Your number was found")
        elif target > val:
            if lower == x:   # this two are the actual lines
                break        # you're looking for
            lower = x
        elif target < val:
            upper = x
a = int(input("Please enter a number between 1 and 10:"))
binary_search([1,5,8,10], a)

In insertion sort, the code looks through the numbers and recognises whether a number is larger or smaller than previously checked numbers. This sorting method actually looks at all previously checked numbers instead of just the previous one. Insertion sort inserts a number where it fits. 

Binary search is an effective search method which uses a middle number to search for another number. In binary search, the middle element in the array is compared to the number that needs to be found. If the number is bigger, then the middle number and everything smaller is removed, but if it is smaller, the middle number and everything bigger is removed. This process is continued until the number is found.


Binary Search Code: https://stackoverflow.com/questions/9501337/binary-search-algorithm-in-python

Insertion Sort Code: https://www.geeksforgeeks.org/insertion-sort/

How does insertion sort work: https://www.khanacademy.org/computing/computer-science/algorithms/insertion-sort/a/insertion-sort

How does Binary Search work: https://www.youtube.com/watch?v=JQhciTuD3E8

Card Trick Reflection

Card trick video:







The three tricks I focused on were bringing the card to the top, three piles trick and the spelling card trick.

The reason that I didn’t choose the spelling card trick was because it was too complicated for me to learn in one evening, considering I had other homework to do. It also seemed like a very difficult card trick because of all the looking at the cards and the counting involved in it. It also seemed like the algorithm was complicated.

I didn’t choose bringing the card to the top because it didn’t seem like it would wow anyone. It also seemed like it needed a lot of practice to be able to pick up 2 cards at once. Although it was an easy algorithm, I still needed a lot of practice.

I ended up choosing the three piles trick because it seemed like it was the only one that would wow people and still be simple. This trick really didn’t involve any sleight of hand and really only had easy rules to follow. The algorithm of this was also simple.

Classes and Objects Reflection

I did the Birthday list class. Here is my code:

I first define my class, which is Birthday_List, then my field variables, name and birthday. After that I initialised the parameters inName and inBirthday then assigned self.name/birthday with inName/inBirthday. I then made two methods. The first one returns self.name, and the second one returns self.birthday. Afterwards I assigned the variables inName and inBirthday as inputs so the user can input their name and birthday. Then I made a variable assigned to the class with the parameters inName and inBirthday. I then used the getName and getBirthday methods to print the users input. My last 2 lines are testers for printing just the name.

Partner search

  1. I can find out where Marcus lives and who he is friends with. I can even find his soundcloud! I know he plays in the school jazz band. I couldn’t find much else.

3. I couldn’t find any big data.

4. I searched the name of my partner and some keywords afterwards. This wasn’t very affective because there isn’t much about Marcus on the internet anyway.

What is big data?

1a. With a partner: 

1b. Alone: 

2. Big data is large amounts of data, generally hundreds of terabytes to a few petabytes worth. This data is usually useful for various reasons, whether it be finding out weather patterns or see peoples feelings towards some topics on twitter. It’s usually not completely useless, and doesn’t help with anything. It is usually gathered through sensors or other measurement devices.

How can data be represented?

  1. Data can be represented in binary, pixels, text.
  2. a.  in this picture I compressed the image from a jpeg into a much lower resolution tif file. This lower res tif file, was 15 times bigger than the original jpeg. Then I compressed the tif file into a jpg file of even worse resolution, and it was still far larger than the original.


Sampling rate is the bitrate that sound is sampled at.


MP3: Most popular audio format.




FLAC (Free lossless audio compression)

ALAC (Apple lossless audio codec)

AIFF (Audio Interchange File format)

WAV (Waveform Audio File Format)



Frequency × bit depth × channels = bit rate.

2 d.  A codec is a decoder that converts digital signals into analogue signals. It decodes the digital signal for playback.

Lossy compression: This type of compression will lose some quality and have a far smaller file size. Mostly, whatever is lost, is generally not perceivable by humans.

Lossless compression: This type of compression does not lose quality but does have a smaller file size.

Blown to Bits reflection

The chapter was about how data is represented and the problems that it can pose. At the beginning it listed out 3-4 instances where data was thought to be hidden but could actually easily be revealed, and this was due to a lack of education. It talked about lossy and lossless compression, as well as how lossless compression maintains same quality but smaller file size. It also talks about how the internet works including the various different protocols and services. It was interesting to read about the fact that different companies had different computing protocols and how the current ones emerged out of the Berkeley Unix operating system. The chapter also talked about cryptography and hiding messages in plain sight, with one way being typing white letters on a white background and printing that onto black paper. I found it very interesting when the chapter talked about how deleted files can still be seen. The research done on what is still on a flash drive even after it has been cleaned was a very interesting research topic and I am interested to find out how to properly sanitise a flash drive.

SSH Reflection

  1. SSH is a way of remotely connecting to a computer by the use of IP Address, Computer name and password. You can control your computer through another computer.
  2. It was easy to connect to my partners computer once it was figured out. At the beginning, everyone forgot to put an s in front of their username. Eventually it worked by putting s(student number)@(IP address) and then putting in the persons password.
  3. I didn’t know that it was through terminal, i thought it was like screen sharing. I also thought it was more like hacking by getting on their computer without them knowing, but you needed their password and their IP Address.
  4. It is unethical because you can control someone else’s computer from far away and delete files and mess with their things.
  5. https://books.google.com.hk/books?id=nERI0SQqF_sC&pg=SA4-PA9&lpg=SA4-PA9&dq=ssh+hacking+ethical&source=bl&ots=TLX1rGobM2&sig=-Qq13dsYuII47SC0_CTdtO2Ys0M&hl=en&sa=X&ved=0ahUKEwj747CxhYTXAhUKVLwKHQ7MBAIQ6AEIQjAG#v=onepage&q=ssh%20hacking%20ethical&f=false