6.00.1x Week 3 (Problem Set)

There are two problems in this week’s problem set, one requires us to calculate the radiation exposure, another one requires us to program a hangman game.

Radiation exposure

Radioactive substance will undergo radioactive decay and emit radiation, over time, the amount of radioactive substance will reduce. The time required for a radioactive substance to reduce half of its amount is called half-life. Different radioactive substance has different half-life. For example, the half-life of Copernicium-285, Cn-285 is 29 seconds, this means if we start off with 4 grams of Cn-285, it will reduce to 2 grams after 29 seconds, and it will reduce to 1 gram in another 29 seconds. Other radioactive substance has long half-life, for example, Uranium-238, U-238 has a half-life of 4.47 billion years, its long half-life makes it useful for radiometric dating.

The amount of radioactive substance at any given time can be plotted as a graph. From the graph below, we can see the amount of radioactive substance/ radioactivity decreases by time.

The problem of this week is, calculate the amount of radioactive exposure for a given time period. If a human were exposed to radioactive substance at time 5 to time 25, how do we know how much radioactivity has accumulated over that time period? The answer is $\mbox{radioactivity accumulated} = \mbox{radioactivity} \times \mbox{time}$, which is the area under the graph.

Then the question is how do we calculate the area under the graph? We can do this by drawing rectangle of height f(x) at given x, and width of a fixed size. From time 5 to time 25, it can be divided into 5 rectangles of width 5, the height will be the f(x) value. This method can only give an approximation of area under the graph, as for each rectangle, there is part of the rectangle that is not in the area under the graph, specifically, the top right corner of rectangle. However, we can improve this approximation by using rectangles of smaller width, say separate the rectangle from time 5 to time 25 into 20 rectangles, with 1 width each, this will reduce the amount of extra part of rectangles that is not in area under the graph.

Hangman

In this game of Hangman, we are given a words.txt file containing many words, which will be chosen at random for our user to guess. The whole script’s main part is as follows:

This is short, however the functions that work behind the scene is long. First, chooseWord function will choose a word randomly from wordlist, which was loaded previously, then assign the word to variable secretWord. The secretWord is passed to hangman function. In this problem set, we need to code the hangman function. hangman function has 3 other functions that can help it do its work, isWordGuessed, getGuessedWord, and getAvailableLetters. Besides coding the hangman function, we also need to code the three functions hangman will later depend on.

isWordGuessedreturns True if all the letters of secretWord are in lettersGuessed (meaning when user finally guessed all the correct letters). getGuessedWord returns string, comprised of letters and underscores that represents what letters in secretWord have been guessed so far ( e.g. _ E _ E P _ O N E). getAvailableLetters returns string, comprised of letters that represents what letters have not yet been guessed.

Then, we code the hangman function. The pseudocode is as follows:

One thought on “6.00.1x Week 3 (Problem Set)”

1. Jed says:

your answer for Radiation exposure not satisfy all conditions. pleaz check and review it.

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