Wednesday, November 13, 2013

Week of November 13

Today, I continued my work on radioactive decay and calculating branching fractions. Using the Review of Particle Physics, I found the five most common decays for the D meson, and I calculated the branching fractions for each of those decays. I spent the majority of my time today working on my Python skills, however.

Today, I reviewed writing functions, using the range function, and writing if-else statements. Dr. Bellis gave me the task of writing a Python program that calculates if a number is prime or not and returns all of the prime numbers under 100. Although the part of the program that returned all of the prime numbers under 100 was fairly simple, I couldn't write that section until I wrote the first one. I knew that to calculate if a number was prime or not, I first had to define a range for the computer to calculate from. I defined the range as all the numbers between 2 (since 1 isn't a prime) and 1 + the square root of the number, since there aren't any new factors of a number after its square root. This is what that section looked like:

I had to use the integer function int() which converts all numbers into integers since the range function only works with integers. The if statement "if number % x == 0" basically says "if the number entered is divided by any number in the defined range, and the answer is equal to 0, then return 'False.' If the answer isn't equal to 0, then return 'True.'"

I wrote the section of the program that checks if the number entered by the user is prime, but there were too many bugs for the program to run successfully. Next time I have my internship, I will continue writing and debugging the program.

1 comment:

  1. Arghh, no branching function! I was so excited to see your calculations. Oh wel ...

    The concept of that book is awesome and shocking. Imagine creating a 1,500 page book!

    I am impressed with your Python skills, and with your mathematical reasoning. You clearly have some solid grounding in numbers.

    If you can, try to couch your weekly post into the larger aspect of your work. How does this post relate the the greater picture of your internship?

    ReplyDelete