How $\pi$ was almost $3.2$

by 6:42 AM
Yes, you read that right. The numerical constant $\pi \approx 3.14$ could have been equal to $3.2$!

In 1894, physician and amateur mathematician Edward J. Goodwin (c.1825-1902) believed that he had found a way to square the circle. It was proven in 1882 that this can't be done by Ferdinand von Lindemann.

How did he do it then? The way he did it implied various wrong values of $\pi$, most commonly $3.2$. Here is an example. He made this diagram, which is a circle with diameter $10$. He then says the circumference is $32$, not $\sim 31.415...$, which means $\pi = 3.2$! However, at the time, $\pi$ was known to 527 correct digits.

He showed this to Indiana state representative Taylor I. Record, so schools could show this as a way to square the circle without royalties. Record then introduced it to the house under the excruciatingly long title "A Bill for an act introducing a new mathematical truth and offered as a contribution to education to be used only by the State of Indiana free of cost by paying any royalties whatever on the same, provided it is accepted and adopted by the official action of the Legislature of 1897". It was bill #246 of the 1897 sitting of the Indiana General Assembly.  

The bill somehow passed the Indiana House of Representatives, and was sent to the Indiana Senate. On the day they were going to vote, Professor Clarence Abiathar Waldo happened to be there. He explained to the Senate that the bill redefined $\pi$, and it actually almost passed, but one senator said that they had no power to define mathematical truth. That is why the Indiana Pi Bill did not pass.

String Manipulation in Scratch

by 4:29 PM
Strings are either single characters, words or sentences. 
Examples of strings: “A”, “b”, “I like Pi”, “$400”, “(^_^)”, “Sentences etc.”

Variables can store strings 

You can pull out individual letters from a String using this block:
Each letter is part of an index that includes spaces.
In the example above, letter 1 is “a”, letter 2 is “p”, and so forth.
If my phrase were “apple juice” instead, letter six would be a space and letter seven would be a “j”.

Please find and write the correct letters based on these four code prompts:

String Concatenation: This refers to the combination of one or more strings using the “join block.” join(“A”,”B”)=”AB”
                                                                        Write Answer here

String Length: the length of the string is simply the number of characters in it. For example length(“I like Pi”) = 9
Write Answer Here

User Input: When we are designing an application, we need to make choices regarding how our program takes in data from the user (person who is using the application). One way is to ask directly.
Once the user has provided a response, it will be held temporarily in the “answer” data block. You can then store it. 


Find letter 15 of the “Friends, Romans, Countrymen” string:

Join two variables with string data (make this difference from the example)

Get the length of this string “102193801232312132312”:

Take in user input (answer a question of your own choice) and store this in a variable. Find the letter 9 (if it exists) and length. Get another piece of user input and join the two strings. Print your final result. 

Experiment with the arithmetic and string operators. What happens when you try to add two strings together?

Challenge: A Chromosome is being built by four letters (‘A’ - Adenine; ‘T’ - Thymine; ‘G’ - Guanine; ‘C’ - Cytosine). Use the random number generator to manually record values between 1-4 on a piece of paper. Create a legend explaining which letter corresponds to which number (i.e. 1-A; 2-T; 3-G; 4-C). Use the join method to create a new string with your gene (i.e. ATGACCCGT).

Utilizing the Scratch API to download comments from a Scratch Studio

by 7:53 PM

Studios in Scratch are collections of Projects centered around a specific “theme”

         If we want to analyze comments from a rather large Scratch studio, the best way to accomplish this via the system built into Scratch currently is to click the “load more” button many times and try to search top-level replies with CTRL+F. This strategy is inefficient when you want to perform whole data-set analysis or simply search all the comments for specific keywords. Although the API is considered deprecated, it can still be used to access the information in HTML format. If you want to access a specific page, you can simply use the following URL.


         The following python3 program can take all the comments from a given studio and sequentially inserts them into a csv file. This format can be opened in most spreadsheet programs. You will need to change the link in the requests.get() command with the specific number associated with the studio.

How to find the number associated with a specific studio

There is also a code segment labelled “analysis”, which produces some high-level information about the studio as shown in the spreadsheet below. It will be unsorted, so you will need to navigate to the appropriate sorting tools within your program, most likely excel or google spreadsheets.

Example of the top-level analysis for the S.D.S. Studio "Growing"
Enjoy utilizing the program for your interests. Please note that it may not work for some exceptionally large studios due to Scratch's built-in rate limit. 

Purpose: Track user contributions within the specific studios

Created by makethebrainhappy

import requests
from bs4 import BeautifulSoup
import pandas as pd
import collections

def main():
    #Data Collection Portion
    users = []
    comments = []
    timestamps = []
    pages = 1
    while True:
        html_doc = requests.get("https://scratch.mit.edu/site-api/comments/gallery/146521/?page="+str(pages))
        if html_doc.status_code == 200:
        elif html_doc.status_code == 404:
            print('Not Found.')
        soup = BeautifulSoup(html_doc.content, 'html.parser')
        for com in soup.find_all("div", class_="comment"):
            users.append(com.select("div.name a")[0].string)
        for com in soup.find_all("div", class_="comment"):
            comments.append(com.select("div.content")[0].get_text(" ",strip=True))
        for com in soup.find_all("div", class_="comment"):
            timestamps.append(com.select("span.time")[0].get_text(" ",strip=True))
        pages = pages + 1
    d = {"user":users,"comment":comments,"timestamp":timestamps}
    df = pd.DataFrame(data=d)
    #Analysis Portion
    newUsers = Counter(users)
    lenComments = []
    for i in comments:
    newDict = {}
    for j in range(0,len(lenComments)):
        newDict[users[j]] = 0
    for j in range(0,len(lenComments)):
        newDict[users[j]] = newDict[users[j]]+lenComments[j]
    newUsers = collections.OrderedDict(sorted(newUsers.items()))
    newDict = collections.OrderedDict(sorted(newDict.items()))
    avg = []
    for j in range(0,len(newUsers)):
    d = {"user":newUsers.keys(),"Number of Comments":newUsers.values(),"Total Characters in Comments:":newDict.values(),"Average Characters per Comment":avg}
    df = pd.DataFrame(data=d)


Credit to apple502j for helping me with beautifulsoup.

Powered by Blogger.