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: 


Leave a Reply

Your email address will not be published. Required fields are marked *