Completely new to the forum so firstly hello to all.
I'm new to programming and am currently teaching myself python with the help of some online tutes etc.
Anyway I've decided to actually write something that may be of use to me, to put it simply it will be a simple little database (which I hope to turn into a GUI at a later date).
Basically the programme will present the user with the following
print "Welcome to DataLoger (HNMR)! V1.0\n"
peaks = raw_input("How many peaks do you you need to enter ?\n")
yorn = raw_input("so thats " + peaks + " peaks: (Y/N) ?\n")
yorn = yorn.lower()
if yorn == 'y':
print "Lets iput data for those peaks !"
elif yorn == 'n':
peaks = raw_input("How many peaks do you you need to enter ?\n")
else:
print "error"
so now I want to take the "peaks" variable, which will be an integer, and create a whole host of variables based on that integer. I then want some code (below) to repeat itself and save data as variables so that they can be later formated, printed and saved to a text doc.
shiftx = raw_input("What is the shift of peak No " + x + ":")
multx = raw_input("What is the multiplicity of peak No " + x + ":")
integrationx = raw_input("What is the integration of peak No " + x + ":")
jcoupx = raw_input("What is the J-coupling of peak No " + x + ":")
so if the original peaks variable is say 4, the above code will repeat 4 times, and the "x" will be 1 -4 so I'll have 4 sets of data shift1, mult1, intergration1, jcoup1......shift4 etc.
I've tried doing a while loop and use the "+" to increment the variables doing something along the lines of this, but it didn't work
x = peaks
while (x != 0)
shift + str(x) = raw_input("What is the shift of peak No " + x + ":")
mult+ str(x) = raw_input("What is the multiplicity of peak No " + x + ":")
integration+ str(x) = raw_input("What is the integration of peak No " + x + ":")
jcoup+ str(x) = raw_input("What is the J-coupling of peak No " + x + ":")
x = x - 1
I've been doing some reading and it looks like using an array is the way to go with this but I have no idea how they'll work for what I want to do (even after reading a few tutorials)
Please be aware that I'm brand new to programming and I may not understand a whole heap of jargon at this time.
And I know this isn't a place to ask for code but if anyone can fine me an example of some code that's doing something similar to what I intend to do here that'd be awesome !
Cheers
Shulgin

New Topic/Question
Reply



MultiQuote



|