Lab Week 2

I believe that it is important for humanities students to learn to code. As a computer science major, I may have some bias in this debate. However, I agree with Kirschenbaum’s argument that programming helps produce creativity and critical thinking skills. Especially with the growing importance of technology in our daily lives, having even a rudimentary understanding of programming could prove beneficial in any field or career. This will allow humanities students to understand how a technological tool is working, rather than thinking of it as a “black box”. Similarly, learning to code will also encourage humanities students to utilize new problem-solving techniques, which could lead to answers and solutions they may not have otherwise considered. Coding is also a very creative activity, essentially building and designing a “world” out of nothing. This can open up new opportunities for humanities students to explore their respective fields and encourage alternative ways of thinking. The following quote stood out to me especially as I was reading Kirschenbaum’s argument.

“More significantly, many of us in the humanities miss the extent to which programming is a creative and generative activity.”

“Hello Worlds (Why Humanities Students Should Learn to Program).” Matthew G. Kirschenbaum, May 26, 2010. https://mkirschenbaum.wordpress.com/2010/05/23/hello-worlds/.

Prior Coding Experience

My first experience with coding was actually through the Alice program that was mentioned in Kirschenbaum’s article. In high school, I took various computer science courses and participated in a few coding competitions at a nearby university. This ultimately led to me choosing to major in computer science when I arrived at Carleton, where I obtained much more experience with coding. I have also worked software engineering internships where my main responsibilities were to produce code for a specific purpose. I find coding to be a very enjoyable activity, almost like solving a puzzle. I believe my coding experiences have introduced me to new ways of problem-solving, which I have been able to apply to my other classes and personal life. The following is a code snippet from my Algorithms class that I took last winter.

#This is an program that will return an array A of length d * f, where d is the number of dice and f is the number of 
#faces on the dice, such that each element A[i] contains the probability that rolling d f-sided die will yield a sum of i.
#CS 252, Problem Set #8
#Reed Schubert, 3/1/2024
import sys

def rollDice(d, f):
    #Makes sure d and f are valid values
    if d <= 0 or f <= 0:
        print("Invalid number of dice or faces on the dice, please enter a positive integer.")
        main()

    #Creates and initalizing the array, 
    maxSize = d * f
    array = [[0]*(maxSize) for i in range(d)]
    #Fills in 1s from index 0 to f in the first row of the array 
    for i in range (f):
        array[0][i] = 1
    
    #In the case there is more than 1 dice being thrown 
    if d > 1: 
        for row in range(1, d):
            sum = 0 
            for column in range (row, maxSize):
                #In the case that a value is out of range of the array, treat it as a 0
                try:
                    oldValue = array[row-1][column-f-1]
                except:
                    oldValue = 0
                newValue = array[row-1][column-1]
                sum -= oldValue
                sum += newValue
                array[row][column] = sum

    #Dividing each value by f to the power of d to get it's final probability of being thrown 
    denomenator = f**d
    for i in range(maxSize):
        array[d-1][i] = array[d-1][i]/denomenator
    return array[d-1]


def main():
    d = sys.argv[1]
    f = sys.argv[2]
    prob = rollDice(int(d), int(f))
    print(prob)

main()


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

css.php