Friday, June 10, 2016

Grace Hopper: Paving the Way Towards Modern Computers



Grace Hopper, known for her efforts in the US Navy and as a computer scientist, contributed to the development of computers as we know them by inventing the compiler. 
      Born in 1906, Grace Hopper was always fascinated with math and science. She studied at Yale, where she became one of the first women to earn a Ph.D in mathematics. However, when the U.S entered World War II, Hopper followed in her grandfather's footsteps and enlisted in the Navy. It was there that Hopper was first introduced to computer science.
       The navy assigned Hopper to the Bureau of Ships Computation project, where she learned to operate the Mark I computer - a colossal electro-mechanical computer that could only perform 3 additions a second. She learned to code, and wrote the first manual for the Mark I. In fact, it is believed that she was the first one to coin the term 'bug' to refer to an error in computer code!
         This happened when the Mark I kept spitting back incorrect numbers from multiplication. Hopper examined the behemoth computer, and discovered a live moth jammed between the contacts. This very moth remains preserved today in the Mark I log book, along with Hopper's note: "first ACTUAL bug found."







          However, in writing the manual for Mark I, Hopper found more than just bugs in the system. She realized that computers are symbol manipulators instead of giant calculators. This notion gave her a new view of coding, because it implies that computers can be used for a wide variety of applications. However, at the time, there was no way for computers to understand these symbols.
           To address this problem, Hopper wrote the A-0 compiler, a system that converts a programmer's input of code to binary instructions the computer can understand. Without a compiler, a computer would be no more than a giant simple calculator.
              Not only did Grace Hopper make a monumental contribution to the applications of computer science, but she also encouraged young people to pursue computer science. As she once said, "The most important thing I've accomplished, other than building the compiler, is training young people. They come to me, you know, and say, "Do you think we can do this?" I say, "Try it." 
                

Thursday, June 9, 2016

Computer Science Feature: Girl Knows Tech!

         If you want to follow another cool computer science website, check out Girl Knows Tech! This website features information about the computer code behind word processing and web developing software such as WordPress.
          You can learn the basics of HTML, a language used to code word processing software and websites. For instance, this post shows you how to write code to make words bold and italicized, display text to the screen, and to add functional links. If you want updates about her posts and interests, follow her on Twitter here: https://twitter.com/girlknowstech!
 

Wednesday, June 8, 2016

Arduino!

Want to try out some electronics programming? You can get started with Arduino, a programmable board able to read input! What can you do with an Arduino?
     The possibilities are endless! The Arduino board contains LEDs and sound output systems, so you can program the Arduino to synchronize flashing lights or compose tunes! Here is Arduino's guide page, and you can also choose from a selection of boards to  purchase on the website: https://www.arduino.cc/en/Guide/HomePage
 Once you have one, how do you use it? I used the fabulous introduction and instructions from the book Sylvia's Super-Awesome Project Book, by 'Super-Awesome' Sylvia! This book contains beginning tutorials for coding and creating Arduino projects that are super cool and easy to follow. If you want to learn Arduino, this is the place to start!

Find Your Perfect Pet Using Python!

           
If you're interested in learning Python, you're probably wondering what you can do with it. It is considerably harder to do a graphic project such as a video game or animation than it is in Scratch, but there are plenty of fabulous beginner projects that you can do!
               One of these projects is a simple quiz. You can use it to study for school, or make a fun personality quiz to give to your friends. I made a quiz that predicts your 'perfect pet' based on your input! I include my code below, and you can use it as a template for your own quiz. This code does not run properly in the browser environment CodeSkulptor because of minor differences in input syntax. However, you will be able to take the quiz if you enter it into the Python launcher on your computer. If you don't have Python, you can still take the quiz manually in the version above the code. 

As you are taking this quiz manually, consider how you might implement it in Python. Try it out, and then see the code below!
 Find Your Perfect Pet: Question 1

1. Where will you most likely want to keep your pet?
A. wherever it wants to go
B. Outdoors around my neighborhood
C. In a tank in my house
D. With me always
E. In the yard and in the house
F. Wherever there are ants

2.  You would ideally like your pet to be...
A. quiet and unobtrusive
B. not be a picky eater
C. fuzzy
D. be loyal
E. scare away burglars
F. eat ants

3. Your favorite thing to do with a pet is...
A. let it be
B. take it outdoors
C. pet it
D. have a close relationship with it
E. scare other people
F. watch it eat ants 

4. How much time per day are you willing to spend with your pet?
A. Whenever my pet wants to spend time with me
B. I don't have much time to spend with my pet
C. Whenever I want to spend time with my pet
D. All the time, whether I want to or not
E. I have a lot of time to spare
F. It depends on how many ants there are

5. How willing are you to provide special food for your pet?
A. Not very
B. My pet will probably eat lots of things it finds outside
C. I understand that my pet might need special food, and I will provide it
D. I am extremely willing to give my pet whatever food it needs, even if it is inconvenient for me
E. I prefer that my pet is a vegetarian
F. I have plenty of ants

6. What would you most likely name your pet?
A. Teeny, Moe, Cici
B. Blacky, Patches, Fred
C. Fluffy, Spot, Bob
D. Fido, Shadow, Ringo
E. Buster, Bruiser, Pebbles
F. Aardy, Varky, Antie


If you entered mostly A's, your perfect pet is...
A PARAMECIUM!

If you entered mostly B's, your perfect pet is...
A BUZZARD!

If you entered mostly C's, your perfect pet is...
BREAD MOLD!

If you entered mostly D's, your perfect pet is...
A LEECH!

If you entered mostly E's, your perfect pet is...
A STEGOSAURUS!

If you entered mostly F's, your perfect pet is...
AN AARDVARK! 


<Code Starts Here>

print ('This quiz shall tell you your ideal pet! Let\'s get started.')
print('First, what is your name?')
name = input()
print(name, ',here is your first question.')
print ('Where will you most likely want to keep your pet?')
print ('a. Wherever it wants to go.')
print ('b. Outdoors around my neighborhood.')
print ('c. In a tank in my house')
print ('d. With me always')
print ('e. in the yard and in the house ')
print ('f. Wherever there are ants.')

answer1 = input()
print('You would ideally like your pet to...')
print('a. quiet and unobtrusive.')
print('b. not be a picky eater. ')
print('c. be fuzzy.')
print('d. be loyal.')
print('e. scare away burglars.')
print('f. eat ants.')
answer2 = input()
print('Your favorite thing to do with a pet is...')
print('a. let it be.')
print('b. take it outdoors')
print('c. pet it.')
print('d. to have a close relationship with it.')
print('e. to scare other people.')
print('f. watch it eat ants.')
answer3 = input()
print('How much time per day are you willing to spend with your pet? ')
print('a. Whenever my pet wants to spend time with me.')
print('b. I don\'t have much time to spend with my pet.')
print('c. Whenever I want to spend time with my pet.')
print('d. All the time, whether I want to or not.')
print('e. I have a lot of time to spare.')
print('f. It depends on how many ants there are.')
answer4 = input()
print(' How willing are you to provide special food for your pet?')
print('a. Not very.')
print('b. My pet will probably eat lots of things it finds outside.')
print('c. I understnd that my pet might need special food, and I will provide it.')
print('d. I am extremely willing to give my pet whatever food it needs, even if it is inconvenient for me.')
print('e. I prefer that my pet is a vegetarian.')
print('f. I have plenty of ants.')
answer5 = input()
print('What would you most likely name your pet?')
print('a. Teeny, Moe, Cici')
print('b. Blacky, Patches, Fred')
print('c. Fluffy, Spot, Bob')
print('d. Fido, Shadow, Ringo ')
print('e. Buster, Bruiser, Pebbles')
print('f. Aardy, Varky, Antie')
answer6 = input()
mylist=[answer1, answer2, answer3, answer4, answer5, answer6]
na =0
nb = 0
nc = 0
nd = 0
ne = 0
for i in mylist:
    if (i == 'f'):
        print(' Your perfect pet is... an AARDVARK!')
        break
    elif (i == 'a'):
        na=na+1
    elif (i == 'b'):
        nb = nb + 1
    elif (i == 'c'):
        nc = nc + 1
    elif (i == 'd'):
        nd = nd + 1
    elif (i == 'e'):
        ne = ne + 1
    elif (na == nb) or (na == nc) or (na == nd) or (na == ne) or (nb == nc) or (nb == nd) or (nb == ne) or (nc == nd) or (nc == ne) or (nd == ne):
        print('Will your pet spend more time indoors or outdoors?')
        putin = input()
        if answer == 'indoors':
            print('Your perfect pet is... either a PARAMECIUM, BREAD MOLD, or LEECH!')
        else:
            print('Your perfect pet is... either a BUZZARD, STEGOSAURUS, or AARDVARK!')
           
       
if (na > nb) and (na > nc)and (na > nd) and (na > ne):
    print('Your perfect pet is... a PARAMECIUM!')
if (nb > na) and (nb > nc) and (nb > nd) and (nb > ne):
    print('Your perfect pet is... a BUZZARD!')
if (nc > na) and (nc > nb) and (nc > nd) and (nc > ne):
    print('Your perfect pet is... BREAD MOLD!')
if (nd > na) and (nd > nb) and (nd > nc) and (nd > ne):
    print('Your perfect pet is... a LEECH!')
if (ne > na) and (ne > nb) and (ne > nc) and (ne > nd):
    print('Your perfect pet is... a STEGOSAURUS!')

   

Tuesday, June 7, 2016

The Next Step: Scratch to Python

 
Once you've learned and experimented in Scratch, it's time to advance to the next level of programming! Python is a language that is both easy to learn and is used by computer scientists for real-world applications. Python shares certain aspects with Scratch, since it has output and input commands and ways to control time and repeat actions. 
      However, you can build more complex function structures with it and need to code commands yourself instead of dragging and dropping them. Though this allows for more interesting programs, it means that you need to translate what you want the computer to do into a form the computer can understand. This means that if you write code and the computer cannot understand it, you receive an error message and your program cannot run. However, don't let this deter you! There are plenty of easy ways to fix errors!
Let's get started!
         What can you do with Python? Python is not as visually oriented as Scratch, so it is considerably harder to create video games and animations. However, you can still create games such as quizzes and logic games, and learn how to do simple video games such as Pong and Asteroids.
          How can you learn Python? First, you need a way to start coding! There are two ways you can do this: download Python on your computer, or use a browser coding environment similar to how you coded in Scratch. If you want to download Python, you can choose the latest version. For the purpose of simple games, the version of Python you have does not matter. Now, you are probably thinking, why download Python when you can just code right in your browser? 
            While the browser environment, CodeSkulptor, is essentially Python, certain commands, particularly for user input, are different. This means there are fewer tutorials for CodeSkulptor. However, I took a great online class through Rice University on Coursera that used CodeSkulptor to create games such as Pong, Blackjack, a logic guessing game, and Asteroids. This class is meant for beginners who have no prior knowledge. At the end of the course, you can code and play your own Asteroids video game!
                However, I would suggest taking this class as an intermediate programmer instead of a beginner. To begin, check out my teacher's awesome online class here on FundaFunda!
 Happy coding!

Ada Lovelace and the Analytical Engine: First Female Computer Programmer

The 19th century mathematician Ada Lovelace is considered “the prophet of the computer age” not only because she wrote the first computer program, but because she also recognized the far-ranging applications of the nascent computing technology. Even before her major accomplishments, Ada showed great mathematical skill at a young age. Through her work with Charles Babbage, the first person to describe a computer-- or, as he called it, the Analytical Engine--,  Ada led to the invention and development of the computer.
          Born in 1815 to the legendary poet Lord Byron, Ada Byron showed herself to be a mathematical prodigy at an early age. She always pursued her mathematical interests, despite the discouragement her family showed because she was a girl.  She was fascinated by equations and numbers, and found solving a math problem extremely rewarding. She once described that solving a problem “made a lovely shape in her head”. However, in 1827, Ada’s mother interrupted her plans, insisting that she pursue ‘useful’ and ‘moral’ interests, because fascination with science was considered improper for a girl. Undeterred, Ada continued her studies and met William Turner, who introduced her to Charles Babbage's ideas and inventions.
Charles Babbage

           At a banquet, Ada heard an intriguing snatch of conversation. William was discussing Babbage’s newly invented Difference Engine, a machine that performed basic mathematical operations. Babbage’s Difference Engine was an application of the rules of finite differences, capable of adding and storing numbers. She watched intently as he turned a dial on the tangle of cogs and wires, numbers beginning to appear on the machine’s brass wheels. With each turn of the dial, the numbers increased by two. When the machine reached 178, the crowd was beginning to fall asleep...until the machine displayed an entirely different number. He had programmed the machine to add 201 to the number obtained after 89 rotations. Ada visited Babbage many times after this, and learned of his new plan for an improved Difference Engine-- the Analytical Engine. This was to be the first computer. Even though it was never constructed, detailed plans existed on paper. These plans led to the construction of the computer. Although the Difference Engine seems like nothing but an elaborate calculator to people today, it laid the foundation for future computer technology.

The Difference Engine
    The Analytical Engine was to have more applications than the Difference Engine, and have a far more complicated structure. How exactly was the Analytical Engine different? Unlike the Difference Engine, which required numbers to be entered by a human, the Analytical Engine used punched cards to do this job. It was also capable of performing more complicated mathematical operations, and needed to be much larger to accommodate all its components. One set of cards determined the operations for the adding and multiplying states of the Analytical Engine. Another set of cards distributed the operations according to a particular function, providing the engine with data and obtainable results. The machine was comprised of four components: the mill, the store, the reader, and the printer. These components are the essential elements of every computer today. The mill was the calculating unit, the equivalent to the central processing unit (CPU) in a modern computer. The store was where data was held, analogous to memory and storage in today’s computers. The reader and printer were the input and output devices. Although today’s computers are more complex, the planned Analytical Engine laid the foundation for the development of computer technology.

Part of the plans for the Analytical Engine
              Not only did Ada contribute to the invention of the Analytical Engine, but she also paved the way for computer programming with the code she wrote for the Analytical Engine. At a presentation of his ideas, Babbage met the Italian mathematician Luigi Menabrea, who was interested in writing a book about the Analytical Engine. However, there was only one problem when the book was published: it was written in French. Due to her voluminous education, Ada was fluent in French. Thus, Babbage referred to Ada to translate the book into English. As well as translating the book, Ada added intricately detailed notes further describing the machine, and its possible applications. 
                In fact, Ada realized something about the Analytical Engine that even Babbage did not see. She saw that, just because one was using numbers in their device, they did not need to be thinking just about numbers. Every computer is doing arithmetic underneath due to its binary code, whether someone is listening to music or programming it to add. Ada was the first to observe possible uses for the computer outside of mathematics, such as composing music. Ada also understood the potential power this machine had, because it could make choices and repeat instructions. In translating and adding to Menabrea’s writing, Ada emphasized the machine’s versatility, explaining how it could solve trigonometric functions including variables, and how it could solve challenging math problems.
Ada’s work with Babbage led to the development of the Analytical Engine, which laid the foundation for the computers we use today. In her honor, the first computer programming language was named ‘Ada’.
   

Monday, June 6, 2016

Computer Science Project: Helping Solve a Problem in Bioinformatics

 
If you have ever been prescribed a drug, or seen an advertisement for one, you have probably noticed the list of potential side effects ranging from dizziness to death. A drug might cure one person, and poison another. I wondered why people respond differently to the same drugs, and decided to pursue a project in bioinformatics -- the science of analyzing genetic data --  to explore this question. I found that genetic mutations affect a person’s response, and coded an algorithm to locate these mutations in a genome. Research in this area could lead to groundbreaking medical innovations that would alleviate suffering by enabling personalized medicine, allowing doctors to create tailor-made treatments based on an individual’s unique genetic composition.
People responding differently to the same drug is a problem of increasing concern. For example, a CDC study found that 120,000 people are hospitalized per year for severe drug reactions. With over 70% of Americans on at least one prescription drug, the possibility of experiencing severe side effects is an imminent and potentially fatal risk. According to a study from the Journals of the American Medical Association, prescription drugs are the fourth leading cause of death in the USA, causing 106,000 deaths per year. This means that severe responses to drugs are a critical health concern.
Could there be a way to predict what drugs an individual will respond to? To help address this problem, I researched what could cause variable responses to some of the most common drugs Lipitor, Plavix, and Tegretol, and found that genetic mutations influence a person’s response. 
However, knowing the mutations only solves half the problem. Doctors need to know if their patients have particular mutations. They need to locate a single base swap in a genome of millions of bases by using a string searching algorithm. String searching algorithms are computer programs that locate a string of characters within a text. In this case, the genome is the text and the mutation, a sequence of base letters, is the string. It is important for the algorithm to produce a result quickly so that doctors can test a large volume of patients conveniently and easily. In addition, a fast algorithm is vital in emergency situations such as seizure or allergic shock when the correct drug must be prescribed immediately.
To help determine an optimal algorithm, I selected two of the most widely used string searching algorithms: Naive Exact Matching and Boyer-Moore, as well as the Boyer-Moore modification Apostolico-Giancarlo, and compared their efficiencies.
Efficiencies are determined by the number of character comparisons and string alignments each algorithm performs. The fewer comparisons and alignments it performs, the faster an algorithm runs. Character comparisons compare a letter in pattern P to a letter in text T, while the alignments compare the whole P to a small segment of T.  Since Boyer-Moore uses an efficient algorithm to skip certain alignments, it takes less time to run than Naive Exact Matching. Apostolico-Giancarlo is more efficient than Boyer-Moore because it stores each compared character in an array. For this reason, I parallelized it, or coded it to run simultaneously on multiple processors, to make it even faster.
    How does parallelism make an algorithm faster?
A parallel program divides the task of searching through a genome by making multiple processors work together on a problem. This reduces the time needed to obtain the solution.

    Structure of a parallel program
parallel_giancarlo.jpg
My results lead me to conclude that a parallelized algorithm is essential to feasible personalized medicine. Further research is needed, as this study only addresses several mutations specific to several drugs, and the Apostolico-Giancarlo algorithm is only one out of hundreds of possibly more efficient algorithms. However, these results suggest that bioinformatics research has the potential to save lives by allowing doctors to make the pill fit the ill.

I also made a video describing my project, which you can find here: https://www.youtube.com/watch?v=Vw3QYrqA99U
 

Getting Started!

Just start coding! The best way to learn how to code is to start coding! Do it now! Wondering how? I started coding when I was 10, beginning with Scratch. 

My first experience with Scratch was through a course taught by my awesome teacher, Mrs. Meryl van der Merwe. Now she has the class online so anybody anywhere can take it! Her site is called FundaFunda, and has a beginner, intermediate, and advanced Scratch class.
 
 I also used tutorials from MIT's scratch page to gain very basic knowledge. Here is the tutorial:  https://scratch.mit.edu/projects/31407152/ 

Now that you know some Scratch, it's time to start coding! If you are dreading following obscure instructions to download Scratch on your computer, never fear! You can open a complete Scratch platform here: https://scratch.mit.edu/projects/editor/?tip_bar=home  There are suggested projects and tutorials on the side.

I suggest starting small. Before you attempt a full game or animation, just experiment with the different blocks. Make the cat sprite move across the blank screen. Once you've tested the individual blocks, try making them interact! Make the cat dance in a whole chunk of code! You can also experiment with the 'looks' and 'sound' tabs by making the cat 'say' something, or drawing a hat on it. Try incorporating time into your program with the 'control' bar, making it wait several seconds before meowing, or making it repeat a motion 10 times.

Once you have experimented with the Scratch cat, you can follow a tutorial to make a game or animation. You can use the tutorials from MIT on your coding page, or use this video to make a platform game: https://www.youtube.com/watch?v=ooPPlj4jFjc

When you've made something based on a tutorial, try elaborating on it or creating your own game or animation! I animated some of Aesop's fables such as the Crow and the Pitcher and the Lion and the Mouse. I advise making a short animation of a simple fable or fairy tale because it is extremely easy to become overwhelmed in a complicated story. 

Once you've made something, share your fabulous project! You can create an account on the site https://scratch.mit.edu/, post your project, and explore what others have done!