Differences between revisions 3 and 13 (spanning 10 versions)
Revision 3 as of 2013-08-21 15:51:44
Size: 199
Editor: mark
Comment:
Revision 13 as of 2013-09-01 10:25:40
Size: 2778
Editor: hassan
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
[[ScrumPy/Doc/Tutorial/PyIntro | Here ]] Before staring with the exercises, have a look at the python tutorial, [[ScrumPy/Doc/Tutorial/PyIntro | here]]. Try to repeat some of the code in your !ScrumPy window.
Line 7: Line 7:
'''(a)''' Start a !ScrumPy session, and make the following assignments:

{{{#!python
>>> num_type_1 = 8
>>> num_type_2 = 9.0
>>> str_type = 'a'
}}}

What do you think the ''value'' and ''type'' of the following expressions are?

{{{
num_type_1/2
num_type_1/2.0
num_type_2/3
5 + 2*10
str_type*4
}}}

Control your answers using Python. Any deviations from expected? Why?


'''(b)''' Create a list with six items, e.g.:
{{{#!python
>>> test_list= ['a', 'b', 'c', 'd', 'e', 'f']
}}}

Make another list (''reversed_list'') that is a copy of the first, e.g.:
{{{#!python
>>> reversed_list=test_list[:]
}}}

(why will this assignment result in a copy of ''test_list''? Hint: this is a ''slicing'' operation.)

Now, reverse the order of the items in ''reversed_list'' by repeating the following assignment with suitable choice of ''n'' and ''m'':

{{{#!python
>>> reversed_list[n]=test_list[m]
}}}

'''(c)''' Define two empty dictionaries, one called ''ara'' the other ''rad''. Both will be used for collection information about plants, ''ara'' about ''Arabidopsis thaliana'', and ''rad'' about radish.

For both dictionaries define the keys ''name'' with a empty dictionary as value, ''usedFor'' and ''relatedTo'' (both with empty lists as values). For the nested dictionaries (''name'') define the keys ''Latin'' (with another empty dictionary as value) and ''English'' with the English name of the plant as value (for ''A. thaliana'' this is ''thale cress''). For the ''Latin'' dictionary define the keys ''genus'' (with the value being the genus name) and ''sp.'' (with the value being the species name). For ''A. thaliana'', ''genus'' is ''Arabidopsis'', ''sp.'' is ''thaliana''. The Latin name for radish is ''Raphanus sativus''.

For both ''ara'' and ''rad'' define the key ''reletedTo'', with an empty list as value. Since the two plants are in the same family, for each dictionary append the other dictionary to the ''relatedTo'' list.

How would you find, using one single command, the English name of an organism that ''A. thaliana'' is related to?

Explore what happens if you try to access the nested ''relatedTo'' organism, starting from any of the two organisms (i.e. start from one organism, access the organism it is related to, then continue down one level to the organism the second organism is related to).


'''(d)''' The volume of a sphere can be calculated as 4/3*&pi;*r<sub>3</sub>

Practical 1

Part 1 - Exploring Python

Before staring with the exercises, have a look at the python tutorial, here. Try to repeat some of the code in your ScrumPy window.

(a) Start a ScrumPy session, and make the following assignments:

   1 >>> num_type_1 = 8
   2 >>> num_type_2 = 9.0
   3 >>> str_type = 'a'

What do you think the value and type of the following expressions are?

num_type_1/2
num_type_1/2.0
num_type_2/3
5 + 2*10
str_type*4

Control your answers using Python. Any deviations from expected? Why?

(b) Create a list with six items, e.g.:

   1 >>> test_list= ['a', 'b', 'c', 'd', 'e', 'f']

Make another list (reversed_list) that is a copy of the first, e.g.:

   1 >>> reversed_list=test_list[:]

(why will this assignment result in a copy of test_list? Hint: this is a slicing operation.)

Now, reverse the order of the items in reversed_list by repeating the following assignment with suitable choice of n and m:

   1 >>> reversed_list[n]=test_list[m]

(c) Define two empty dictionaries, one called ara the other rad. Both will be used for collection information about plants, ara about Arabidopsis thaliana, and rad about radish.

For both dictionaries define the keys name with a empty dictionary as value, usedFor and relatedTo (both with empty lists as values). For the nested dictionaries (name) define the keys Latin (with another empty dictionary as value) and English with the English name of the plant as value (for A. thaliana this is thale cress). For the Latin dictionary define the keys genus (with the value being the genus name) and sp. (with the value being the species name). For A. thaliana, genus is Arabidopsis, sp. is thaliana. The Latin name for radish is Raphanus sativus.

For both ara and rad define the key reletedTo, with an empty list as value. Since the two plants are in the same family, for each dictionary append the other dictionary to the relatedTo list.

How would you find, using one single command, the English name of an organism that A. thaliana is related to?

Explore what happens if you try to access the nested relatedTo organism, starting from any of the two organisms (i.e. start from one organism, access the organism it is related to, then continue down one level to the organism the second organism is related to).

(d) The volume of a sphere can be calculated as 4/3*π*r<sub>3</sub>

Part 2 - Creating Models

Part 3 - The Stoichiometry Matrix and Null-space

None: AccliPhot/WorkshopOne/prac1 (last edited 2014-12-16 12:30:53 by david)