So I am creating a python script that is a menu with sub menus that take data from sensors, there are 16 sensors:

S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15 and S16.

Since the data needs to clear I want to take the average value of five sensor data like:

- Code: Select all
`S1TA = (S1A + S1B + S1C + S1D + S1E) / 5`

Lets call this project A:

I know that would be the script to get it to work but I don't know how to set it up where the the first value is read as S1A and the second value S1B. So I need to know how to set up this program.

Project B:

I need menus to deal with add a values of weight such as: 5, 10, 15, 25, 50, 100, 500, 1000 and 5000; I have created this:

- Code: Select all
`while ans2:`

print("=============================================")

print("==== Adding weight on the polymer Bridge ====")

print("=============================================")

print(""

I. Add 1 gram:

II. Add 5 grams:

III. Add 10 grams:

IV. Add 25 grams:

V. Add 50 grams:

VI. Add 100 grams:

VII. Add 500 grams:

VIII. Add 1 kiligram:

IX. Add 5 kiligrams:

X. Add 10 kiligrams:

XII. Exit to main menu: \n "")

ans2 = input("How much do you wish to add?")

if ans2 == "1"

X1 = 1

WeightTotal + X1 = WeightTotal

print("Totals Weight on the bridge is now XT grams")

ans22 = input ("Please press enter to to take Voltages:")

if ans21 == "Enter"

elif ans!="":

print("\n I am sorry I cannot do that")

if ans2 == "2"

X2 = 5

WeightTotal + X2 = WeightTotal

print("Totals Weight on the bridge is now XT")

ans22 = input ("Please press enter to to take Voltages:")

if ans22 == "Enter"

elif ans!="":

print("\n I am sorry I cannot do that")

if ans2 == "3"

X3 = 10

WeightTotal + X3 = WeightTotal

print("Totals Weight on the bridge is now XT grams")

ans23 = input ("Please press enter to to take Voltages:")

if ans23 == "Enter"

elif ans!="":

print("\n I am sorry I cannot do that")

if ans2 == "4"

X4 = 25

WeightTotal + X4 = WeightTotal

print("Totals Weight on the bridge is now XT grams")

ans14 = input ("Please press enter to to take Voltages:")

if ans14 == "Enter"

elif ans!="":

print("\n I am sorry I cannot do that")

if ans2 == "5"

X4 = 50

WeightTotal + X5 = WeightTotal

print("Totals Weight on the bridge is now XT grams")

ans25 = input ("Please press enter to to take Voltages:")

if ans25 == "Enter"

elif ans!="":

print("\n I am sorry I cannot do that")

if ans2 == "6"

X6 = 100

WeightTotal + X5 = WeightTotal

print("Totals Weight on the bridge is now XT grams")

ans26 = input ("Please press enter to to take Voltages:")

if ans16 == "Enter"

elif ans!="":

print("\n I am sorry I cannot do that")

if ans2 == "7"

X7 = 500

WeightTotal + X5 = WeightTotal

print("Totals Weight on the bridge is now XT grams")

ans27 = input ("Please press enter to to take Voltages:")

if ans27 == "Enter"

elif ans!="":

print("\n I am sorry I cannot do that")

if ans2 == "8"

X8 = 1000

WeightTotal + X5 = WeightTotal

print("Totals Weight on the bridge is now XT grams")

ans28 = input ("Please press enter to to take Voltages:")

if ans18 == "Enter"

elif ans!="":

print("\n I am sorry I cannot do that")

if ans2 == "9"

X9 = 5000

WeightTotal + X9 = WeightTotal

print("Totals Weight on the bridge is now XT grams")

ans29 = input ("Please press enter to to take Voltages:")

if ans29 == "Enter"

So than I want it to do project A, and take the average value of five interactions of each sensor.

Which than I want it to save the data in a new line of txt after each addition of weight like this:

- Code: Select all
`Weighttotal, S1TA, S2TA, S3TA, S4TA, S5TA, S6TA, S7TA, S8TA, S9TA, S10TA, S11TA, S12TA, S13TA, S14TA, S15TA, S16TA`

However, I do not know how to save this data into a txt file nor do I know how to exit the menu.

Part two is gong to be the same but instead of adding weights it removing weights. Thank you for your help ahead of time.