Advertisement
Guest User

My Python Script

a guest
Aug 9th, 2012
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 27.10 KB | None | 0 0
  1. import math
  2.  
  3. # 5 possible values calculated in SUVAT equations
  4. variables = ["s", "u", "v", "a", "t"]
  5.  
  6. while True:
  7.     # choice1 is what the user is looking to calculate
  8.     choice1 = raw_input("Welcome to Mattin's SUVAT Simulator! Choose the value you are trying to find. You can pick from " + str(variables))
  9.     if choice1 in variables:
  10.         print "You chave chosen to find", choice1
  11.         variables = [v for v in variables if v != choice1] # Will delete the chosen variable from the list
  12.         break
  13.  
  14. # This error message will show if the input did not match any item in the list
  15.     else:
  16.         print "Sorry, I didn't understand that, try again. Make sure your spelling is correct (Case Sensitive), and that you did not inlcude the quotation marks."
  17.  
  18.  
  19. # # # # # # # Chosing the Variables the user already has values for # # # # # # # #
  20.  
  21.  
  22. while True:
  23.     choice2 = raw_input("Choose the first of the values you already have. You can pick from " + str(variables))
  24.     if choice2 in variables:
  25.         print "You chave chosen", choice2
  26.         variables = [v for v in variables if v != choice2] # Will delete the chosen variable from the list
  27.         break
  28. # This error message will show if the input did not match any item in the list
  29.     else:
  30.         print "Sorry, I didn't understand that, try again. Make sure your spelling is correct (Case Sensitive), and that you did not inlcude the quotation marks."
  31.  
  32.  
  33. while True:
  34.     choice3 = raw_input("Choose the second of values you already have. You can pick from " + str(variables))
  35.     if choice3 in variables:
  36.         print "You chave chosen", choice3
  37.         variables = [v for v in variables if v != choice3] # Will delete the chosen variable from the list
  38.         break
  39. # This error message will show if the input did not match any item in the list
  40.     else:
  41.         print "Sorry, I didn't understand that, try again. Make sure your spelling is correct (Case Sensitive), and that you did not inlcude the quotation marks."
  42.  
  43. while True:
  44.     choice4 = raw_input("Choose the third of values you already have. You can pick from " + str(variables))
  45.     if choice4 in variables:
  46.         print "You chave chosen", choice4
  47.         variables = [v for v in variables if v != choice4] # Will delete the chosen variable from the list
  48.         break
  49. # This error message will show if the input did not match any item in the list
  50.     else:
  51.         print "Sorry, I didn't understand that, try again. Make sure your spelling is correct (Case Sensitive), and that you did not inlcude the quotation marks."
  52.  
  53.  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  54.  
  55.  
  56.  
  57. # #################################------------###################################
  58. # ################################# v = u + at ###################################
  59. # #################################------------###################################
  60.  
  61. if variables[0] == "s":
  62.  
  63. # # # Finding Values  # # #
  64.  
  65.  
  66.     if choice1 =="u":
  67.  
  68.         while True:
  69.             v = raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  70.             try:
  71.                 float(v)
  72.                 print "v is " + str(v) + " ms^-1"
  73.                 break
  74.             except:
  75.                 print"You must enter a number. Don't include units!"
  76.  
  77.         while True:
  78.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  79.             try:
  80.                 float(a)
  81.                 print "a is " + str(a) + " ms^-2"
  82.                 break
  83.             except:
  84.                 print"You must enter a number. Don't include units!"
  85.  
  86.         while True:
  87.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  88.             try:
  89.                 float(t)
  90.                 print "t is " + str(t) + " s"
  91.                 break
  92.             except:
  93.                 print"You must enter a number. Don't include units!"
  94.  
  95.         u =  float(v) - float(a) * float(t)
  96.         print "u =", u, "ms^-1"
  97.  
  98.  
  99.     elif choice1 == "v":
  100.  
  101.         while True:
  102.             u = raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  103.             try:
  104.                 float(u)
  105.                 print "u is " + str(u) + " ms^-1"
  106.                 break
  107.             except:
  108.                 print"You must enter a number. Don't include units!"
  109.  
  110.         while True:
  111.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  112.             try:
  113.                 float(a)
  114.                 print "a is " + str(a) + " ms^-2"
  115.                 break
  116.             except:
  117.                 print"You must enter a number. Don't include units!"
  118.  
  119.         while True:
  120.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  121.             try:
  122.                 float(t)
  123.                 print "time " + str(t) + " s"
  124.                 break
  125.             except:
  126.                 print"You must enter a number. Don't include units!"
  127.  
  128.         v = float(u) + float(a) * float(t)
  129.         print "v = ", v, "ms^-1"
  130.  
  131.     elif choice1 == "a":
  132.  
  133.         while True:
  134.             u = raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  135.             try:
  136.                 float(u)
  137.                 print "u is " + str(u) + " ms^-1"
  138.                 break
  139.             except:
  140.                 print"You must enter a number. Don't include units!"
  141.  
  142.         while True:
  143.             v = raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  144.             try:
  145.                 float(v)
  146.                 print "v is " + str(v) + " ms^-1"
  147.                 break
  148.             except:
  149.                 print"You must enter a number. Don't include units!"
  150.  
  151.         while True:
  152.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  153.             try:
  154.                 float(t)
  155.                 print "t " + str(t) + " s"
  156.                 break
  157.             except:
  158.                 print"You must enter a number. Don't include units!"
  159.  
  160.         a = (float(v) - float(u)) / float(t)
  161.         print "a =", a
  162.  
  163.     elif choice1 =="t":
  164.  
  165.         while True:
  166.             u = raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  167.             try:
  168.                 float(u)
  169.                 print "u is " + str(u) + " ms^-1"
  170.                 break
  171.             except:
  172.                 print"You must enter a number. Don't include units!"
  173.  
  174.         while True:
  175.             v = raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  176.             try:
  177.                 float(v)
  178.                 print "v is " + str(v) + " ms^-1"
  179.                 break
  180.             except:
  181.                 print"You must enter a number. Don't include units!"
  182.  
  183.         while True:
  184.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  185.             try:
  186.                 float(a)
  187.                 print "a is " + str(a) + " ms^-2"
  188.                 break
  189.             except:
  190.                 print"You must enter a number. Don't include units!"
  191.  
  192.         t = (float(v) - float(u)) / float(a)
  193.         print "t =", t, "s"
  194.  
  195. # ##############################------------------###############################
  196. # ############################# s = vt - 1/2 at^2 ###############################
  197. # #############################-------------------###############################
  198.  
  199.  
  200. if variables[0] == "u":
  201.  
  202.     if choice1 =="s":
  203.  
  204.         while True:
  205.             v = raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  206.             try:
  207.                 float(v)
  208.                 print "v is " + str(v) + " ms^-1"
  209.                 break
  210.             except:
  211.                 print"You must enter a number. Don't include units!"
  212.  
  213.         while True:
  214.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  215.             try:
  216.                 float(a)
  217.                 print "a is " + str(a) + " ms^-2"
  218.                 break
  219.             except:
  220.                 print"You must enter a number. Don't include units!"
  221.  
  222.         while True:
  223.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  224.             try:
  225.                 float(t)
  226.                 print "t is " + str(t) + " s"
  227.                 break
  228.             except:
  229.                 print"You must enter a number. Don't include units!"
  230.  
  231.         s = float(v) * float(t) - (float(a) * float(t)**2) / 2
  232.  
  233.  
  234.     elif choice1 == "v":
  235.  
  236.         while True:
  237.             s = raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  238.             try:
  239.                 float(s)
  240.                 print "s is " + str(s) + " m"
  241.                 break
  242.             except:
  243.                 print"You must enter a number. Don't include units!"
  244.  
  245.         while True:
  246.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  247.             try:
  248.                 float(a)
  249.                 print "a is " + str(a) + " ms^-2"
  250.                 break
  251.             except:
  252.                 print"You must enter a number. Don't include units!"
  253.  
  254.         while True:
  255.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  256.             try:
  257.                 float(t)
  258.                 print "time " + str(t) + " s"
  259.                 break
  260.             except:
  261.                 print"You must enter a number. Don't include units!"
  262.  
  263.         v = (float(s) + (float(a) * float(t)**2) / 2) / float(t)
  264.  
  265.     elif choice1 == "a":
  266.  
  267.         while True:
  268.             s = raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  269.             try:
  270.                 float(s)
  271.                 print "s is " + str(s) + " m"
  272.                 break
  273.             except:
  274.                 print"You must enter a number. Don't include units!"
  275.  
  276.         while True:
  277.             v = raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  278.             try:
  279.                 float(v)
  280.                 print "v is " + str(v) + " ms^-1"
  281.                 break
  282.             except:
  283.                 print"You must enter a number. Don't include units!"
  284.  
  285.         while True:
  286.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  287.             try:
  288.                 float(t)
  289.                 print "t " + str(t) + " s"
  290.                 break
  291.             except:
  292.                 print"You must enter a number. Don't include units!"
  293.  
  294.         a = ((-2)(float(s) - float(v) * float(t))) / float(t)**2
  295.         print "a =", a
  296.  
  297.     elif choice1 =="t":
  298.  
  299.         while True:
  300.             s = raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  301.             try:
  302.                 float(s)
  303.                 print "u is " + str(s) + " m"
  304.                 break
  305.             except:
  306.                 print"You must enter a number. Don't include units!"
  307.  
  308.         while True:
  309.             v = raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  310.             try:
  311.                 float(v)
  312.                 print "v is " + str(v) + " ms^-1"
  313.                 break
  314.             except:
  315.                 print"You must enter a number. Don't include units!"
  316.  
  317.         while True:
  318.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  319.             try:
  320.                 float(a)
  321.                 print "a is " + str(a) + " ms^-2"
  322.                 break
  323.             except:
  324.                 print"You must enter a number. Don't include units!"
  325.  
  326.         t = (float(v) - math.sqrt(float(v)**2 - (2 * float(a) * float(s))))/ float(a)
  327.         print "t =", t,"s"
  328.  
  329. # ####################################--------------------#################################
  330. # #################################### s = ut + 1/2 at^2 ##################################
  331. # ###################################--------------------##################################
  332.  
  333. if variables[0] == "v":
  334.  
  335.     if choice1 =="s":
  336.  
  337.         while True:
  338.             u = raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  339.             try:
  340.                 float(u)
  341.                 print "u is " + str(u) + " ms^-1"
  342.                 break
  343.             except:
  344.                 print"You must enter a number. Don't include units!"
  345.  
  346.         while True:
  347.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  348.             try:
  349.                 float(a)
  350.                 print "a is " + str(a) + " ms^-2"
  351.                 break
  352.             except:
  353.                 print"You must enter a number. Don't include units!"
  354.  
  355.         while True:
  356.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  357.             try:
  358.                 float(t)
  359.                 print "t is " + str(t) + " s"
  360.                 break
  361.             except:
  362.                 print"You must enter a number. Don't include units!"
  363.  
  364.         s = float(u) * float(t) + (float(a) * float(t)**2) / 2
  365.         print "s =", s, "m"
  366.  
  367.     elif choice1 =="u":
  368.  
  369.         while True:
  370.             s = raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  371.             try:
  372.                 float(s)
  373.                 print "s is " + str(s) + " m"
  374.                 break
  375.             except:
  376.                 print"You must enter a number. Don't include units!"
  377.  
  378.         while True:
  379.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  380.             try:
  381.                 float(a)
  382.                 print "a is " + str(a) + " ms^-2"
  383.                 break
  384.             except:
  385.                 print"You must enter a number. Don't include units!"
  386.  
  387.         while True:
  388.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  389.             try:
  390.                 float(t)
  391.                 print "t is " + str(t) + " s"
  392.                 break
  393.             except:
  394.                 print"You must enter a number. Don't include units!"
  395.  
  396.         u = (float(s) - (float(a) * float(t)**2) / 2) / float(t)
  397.         print "u=", u, "ms^-1"
  398.  
  399.     elif choice1 =="a":
  400.  
  401.         while True:
  402.             s = raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  403.             try:
  404.                 float(s)
  405.                 print "s is " + str(s) + " m"
  406.                 break
  407.             except:
  408.                 print"You must enter a number. Don't include units!"
  409.  
  410.         while True:
  411.             u = raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  412.             try:
  413.                 float(u)
  414.                 print "u is " + str(u) + " ms^-1"
  415.                 break
  416.             except:
  417.                 print"You must enter a number. Don't include units!"
  418.  
  419.         while True:
  420.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  421.             try:
  422.                 float(t)
  423.                 print "t is " + str(t) + " s"
  424.                 break
  425.             except:
  426.                 print"You must enter a number. Don't include units!"
  427.  
  428.         a = (2(float(s) - (float(u) * float(t)))) / float(t)**2
  429.         print "a =", a, "ms^-2"
  430.  
  431.  
  432.     elif choice1 =="t":
  433.  
  434.         while True:
  435.             s = raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  436.             try:
  437.                 float(s)
  438.                 print "s is " + str(s) + " m"
  439.                 break
  440.             except:
  441.                 print"You must enter a number. Don't include units!"
  442.  
  443.         while True:
  444.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  445.             try:
  446.                 float(a)
  447.                 print "a is " + str(a) + " ms^-2"
  448.                 break
  449.             except:
  450.                 print"You must enter a number. Don't include units!"
  451.  
  452.         while True:
  453.             u = raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  454.             try:
  455.                 float(u)
  456.                 print "u is " + str(u) + " ms^-1"
  457.                 break
  458.             except:
  459.                 print"You must enter a number. Don't include units!"
  460.  
  461.         t = - (math.sqrt((2 * float(a) * float(s)) + float(u)**2) + float(u)) / float(a)
  462.         print "t =", t, "s"
  463.  
  464. # ################################-------------------##############################
  465. # ############################### s = ((v + u) / 2)t ##############################
  466. # ###############################--------------------##############################
  467.  
  468. if variables[0] == "a":
  469.  
  470.     if choice1 =="s":
  471.  
  472.         while True:
  473.             v = raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  474.             try:
  475.                 float(v)
  476.                 print "v is " + str(v) + " ms^-1"
  477.                 break
  478.             except:
  479.                 print"You must enter a number. Don't include units!"
  480.  
  481.         while True:
  482.             u = raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  483.             try:
  484.                 float(u)
  485.                 print "u is " + str(u) + " ms^-1"
  486.                 break
  487.             except:
  488.                 print"You must enter a number. Don't include units!"
  489.  
  490.         while True:
  491.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  492.             try:
  493.                 float(t)
  494.                 print "t is " + str(t) + " s"
  495.                 break
  496.             except:
  497.                 print"You must enter a number. Don't include units!"
  498.  
  499.         s = ((float(v) + float(u)) / 2) * float(t)
  500.         print "s =", s, "m"
  501.  
  502.     elif choice1 =="u":
  503.  
  504.         while True:
  505.             s = raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  506.             try:
  507.                 float(s)
  508.                 print "s is " + str(s) + " m"
  509.                 break
  510.             except:
  511.                 print"You must enter a number. Don't include units!"
  512.  
  513.         while True:
  514.             v= raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  515.             try:
  516.                 float(v)
  517.                 print "v is " + str(v) + " ms^-1"
  518.                 break
  519.             except:
  520.                 print"You must enter a number. Don't include units!"
  521.  
  522.         while True:
  523.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  524.             try:
  525.                 float(t)
  526.                 print "t is " + str(t) + " s"
  527.                 break
  528.             except:
  529.                 print"You must enter a number. Don't include units!"
  530.  
  531.         u = (2 * float(s) / float(t)) - float(v)
  532.         print "u =", u, "ms^-1"
  533.  
  534.     elif choice1 == "v":
  535.  
  536.         while True:
  537.             s = raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  538.             try:
  539.                 float(s)
  540.                 print "s is " + str(s) + " m"
  541.                 break
  542.             except:
  543.                 print"You must enter a number. Don't include units!"
  544.  
  545.         while True:
  546.             u= raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  547.             try:
  548.                 float(u)
  549.                 print "u is " + str(u) + " ms^-1"
  550.                 break
  551.             except:
  552.                 print"You must enter a number. Don't include units!"
  553.  
  554.         while True:
  555.             t = raw_input("What is the value of t? Make sure it is in standard units, however, do not include the unit.")
  556.             try:
  557.                 float(t)
  558.                 print "t is " + str(t) + " s"
  559.                 break
  560.             except:
  561.                 print"You must enter a number. Don't include units!"
  562.  
  563.         v = (2 * float(s) / float(t)) - float(u)
  564.         print "v =", v, "ms^-1"
  565.  
  566.  
  567.     elif  choice1 == "t":
  568.  
  569.         while True:
  570.             s = raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  571.             try:
  572.                 float(s)
  573.                 print "s is " + str(s) + " m"
  574.                 break
  575.             except:
  576.                 print"You must enter a number. Don't include units!"
  577.  
  578.         while True:
  579.             u= raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  580.             try:
  581.                 float(u)
  582.                 print "u is " + str(u) + " ms^-1"
  583.                 break
  584.             except:
  585.                 print"You must enter a number. Don't include units!"
  586.  
  587.         while True:
  588.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  589.             try:
  590.                 float(a)
  591.                 print "a is " + str(a) + " ms^-2"
  592.                 break
  593.             except:
  594.                 print"You must enter a number. Don't include units!"
  595.  
  596.         t = float(s) - ((float(v) +float(u)) / 2)
  597.  
  598.  
  599.  
  600. # ###################################-----------------###############################
  601. # ################################### v^2 = u^2 + 2as ###############################
  602. # ###################################-----------------###############################
  603.  
  604. if variables[0] == "t":
  605.  
  606.     if choice1 == "s":
  607.  
  608.         while True:
  609.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  610.             try:
  611.                 float(a)
  612.                 print "a is " + str(a) + " ms^-2"
  613.                 break
  614.             except:
  615.                 print"You must enter a number. Don't include units!"
  616.  
  617.         while True:
  618.             u= raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  619.             try:
  620.                 float(u)
  621.                 print "u is " + str(u) + " ms^-1"
  622.                 break
  623.             except:
  624.                 print"You must enter a number. Don't include units!"
  625.  
  626.         while True:
  627.             v = raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  628.             try:
  629.                 float(v)
  630.                 print "v is " + str(v) + " ms^-1"
  631.                 break
  632.             except:
  633.                 print"You must enter a number. Don't include units!"
  634.  
  635.         s = (float(v)**2 - float(u)**2) / 2 * float(a)
  636.         print "s =", s, "m"
  637.  
  638.     if choice1 == "u":
  639.  
  640.         while True:
  641.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  642.             try:
  643.                 float(a)
  644.                 print "a is " + str(a) + " ms^-2"
  645.  
  646.                 break
  647.             except:
  648.                 print"You must enter a number. Don't include units!"
  649.  
  650.         while True:
  651.             s= raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  652.             try:
  653.                 float(s)
  654.                 print "s is " + str(s) + " m"
  655.                 break
  656.             except:
  657.                 print"You must enter a number. Don't include units!"
  658.  
  659.         while True:
  660.             v = raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  661.             try:
  662.                 float(v)
  663.                 print "v is " + str(v) + " ms^-1"
  664.                 break
  665.             except:
  666.                 print"You must enter a number. Don't include units!"
  667.  
  668.         u = math.sqrt(float(v)**2 - 2(float(a) * float(s)))
  669.         print "u =", u, "ms^-1"
  670.  
  671.     if choice1 == "v":
  672.  
  673.         while True:
  674.             a = raw_input("What is the value of a? Make sure it is in standard units, however, do not include the unit.")
  675.             try:
  676.                 float(a)
  677.                 print "a is " + str(a) + " ms^-2"
  678.                 break
  679.             except:
  680.                 print"You must enter a number. Don't include units!"
  681.  
  682.         while True:
  683.             u= raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  684.             try:
  685.                 float(u)
  686.                 print "u is " + str(u) + " ms^-1"
  687.                 break
  688.             except:
  689.                 print"You must enter a number. Don't include units!"
  690.  
  691.         while True:
  692.             s = raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  693.             try:
  694.                 float(v)
  695.                 print "s is " + str(s) + " m"
  696.                 break
  697.             except:
  698.                 print"You must enter a number. Don't include units!"
  699.  
  700.         v = math.sqrt(float(u)**2 + 2 * float(a) * float(s))
  701.         print "v =", v, "ms^-1"
  702.  
  703.     if choice1 == "a":
  704.  
  705.         while True:
  706.             s = raw_input("What is the value of s? Make sure it is in standard units, however, do not include the unit.")
  707.             try:
  708.                 float(s)
  709.                 print "s is " + str(s) + " m"
  710.                 break
  711.             except:
  712.                 print"You must enter a number. Don't include units!"
  713.  
  714.         while True:
  715.             u= raw_input("What is the value of u? Make sure it is in standard units, however, do not include the unit.")
  716.             try:
  717.                 float(u)
  718.                 print "u is " + str(u) + " ms^-1"
  719.                 break
  720.             except:
  721.                 print"You must enter a number. Don't include units!"
  722.  
  723.         while True:
  724.             v = raw_input("What is the value of v? Make sure it is in standard units, however, do not include the unit.")
  725.             try:
  726.                 float(v)
  727.                 print "v is " + str(v) + " ms^-1"
  728.                 break
  729.             except:
  730.                 print"You must enter a number. Don't include units!"
  731.  
  732.         a = (float(v)**2 - float(u)**2) / 2 * float(s)
  733.         print "a =", a, "ms^-2"
  734.  
  735.  
  736.  
  737. raw_input("Thank you for using Mattin's SUVAT simulator. Hit enter to end the program.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement