See the index page for context.
#!/usr/bin/python # Translation of program "COMPUT" (solution 1) from D.M. Etter, # _Structured FORTRAN 77 for Engineers and Scientists_, p.93 # This program computes the average of a set of experimental data # values. sum = 0.0 count = 0 x = float(raw_input("")) while x!=0.0: sum = sum+x count = count+1 x = float(raw_input("")) averg = sum/float(count) print "The average is %6.2f\n" % (averg) # Notes: # # The basics of the while loop and comparison operators can be found # in the original Python tutorials, e.g. # http://www.python.org/doc/2.5.2/tut/node5.html#SECTION005200000000000000000 # # And in Python, indentation is how you indicate a nested block of code.
#!/usr/bin/python # Translation of program "ANALYZ" from D.M. Etter, _Structured FORTRAN # 77 for Engineers and Scientists_, p.94 # This program determines maximum and minimum values and the range of # values for a set of data values. x = float(raw_input("")) max = x min = x x = float(raw_input("")) while x!=0.0: if x>max: max = x