The weekend's experiment was a bust. A good experience, but the IPND is too robust to be properly completed in a mere 72 hours. That's good news for students. The portfolio projects themselves may be able to be completed in that kind of a time frame, but then the meat of the nanodegree is missed. So I'm adjusting my goal to one project per week.
Stage 2: Work Session 4:
Working on systematically breaking down a problem. Going to take an input of "TITLE:" and "DESCRIPTION:" and we want it to look like
<div class="concept"> <div class="title"> title 1 </div> <div class="description"> description 1 </div> </div>
A function is needed to convert the input to the desired output. Break big problems down into smaller parts. Create solutions to the small problems then tie it all together. The function that we create will accept a second input for the HTML. Sometimes working backwards from what you know you can do is easier.
For this particular problem we're going to create a function called get_concept_by_number that will take the input and break it into TITLE and DESCRIPTION by number. Then we'll create two functions, one will get_title and the other will get_description. We'll use the get_title and get_description outputs in a function called generate_concept_HTML. This will output the HTML!
2.6 Structured Data: Lists & For Loops
Introduction to an object called a list.
A string is structured data because it can be broken down into its characters. In a string a sequence of characters is contained within quotes. In a List characters are contained in an array (square brackets) and separated by commas. Lists can be accessed using square brackets and numbers. i.e. p[0] or p[2,4]. This second call will return a list of elements.
Lists can call subs of subs so if you have a list of countries
# Name Capital Populations (millions)
countries = [['China','Beijing',1350],
['India','Delhi',1210],
['Romania','Bucharest',21],
['United States','Washington',307]]
To call Delhi type: print countries[1][1] and it will print the 1 item in the 1 list, 'Delhi'
If we want to know how many times greater China's population is to Romanias we can type:
print countires[0][2] / countries[2][2] and python will do that math.
#floored
Lists work by using two concepts: Mutation and Aliasing.
Lists support Mutation (yes they are a friend to the X-Men). This means the value of a list can be changed after it has been created
That's enough for this post..