clodemil
unread,Mar 26, 2011, 6:32:54 AM3/26/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage-support
Hi All,
Measurements are taken for blood pressure and entered as 3-tuples:
[P_systolic,P_diastolic,Pulse_rate] and put in a list
mesures=[[172,91,57],[181,88,58],[146,88,56],[191,85,59],[171,92,50],
[157,93,55],[180,84,48],[142,77,60],[169,80,45],[162,76,59],
[167,104,73],[166,81,53],[145,78,59],[163,98,58],[192,90,50],
[184,85,60],[151,77,56]]
Various elements or the whole tuple are then used for diverse
calculations and yet again output in lists.
A new measurement entails updating ALL lists individually. So the idea
is to make it automatic using accessory variables x and y and extract
elements thereof.
mesures=[[172,91,57],[181,88,58],[146,88,56],[191,85,59],[171,92,50],
[157,93,55],[180,84,48],[142,77,60],[169,80,45],[162,76,59],
[167,104,73],[166,81,53],[145,78,59],[163,98,58],[192,90,50],
[184,85,60],[151,77,56]]
# [[P systolic,P diastolic,Pulse rate]]
temps=[1,18,24,28,49,87,101,108,113,116,122,133,156,161,166,170,180] #
Hours
Sys=[172,181,146,191,171,157,180,142,169,162,167,166,145,163,192,184,151]
Dia=[91,88,88,85,92,93,84,77,80,76,104,81,78,98,90,85,77]
Pulse=[57,58,56,59,50,55,48,60,45,59,73,53,59,58,50,60,77]
control=[len(temps),len(Sys),len(Dia),len(Pulse)] #all should be equal
x=[[185,82,57]] #new value to be appended to mesures
y=185 #new value to be appended to temps
mesures=mesures+x #appending new value
temps=temps + [y] #appending new value
Sys=Sys + [x[0][0]] #appending new value
Dia + [x[0][1]] #appending new value
Pulse + [x[0][2]] #appending new value
print control
print(mesures)
print temps
print Sys
JOY: It works
DISAPPOINTMENT: It works ONLY if I call the lists on their own and NOT
if they are called inside another cell:
they then appear in the original unappended form:
for i,j in enumerate(temps):
for k,l in enumerate(mesures):
for m,n in enumerate(heuresF):
if m==k:
if i==k:
print "Mesure n°",i,l,n
What am I doing wrong ?
TIA.
Claude