Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- # Name of the file is Riemann.py
- # Created by Joshua Kim on November 26, 2014
- import sys
- # this handy bit of code will see if there is an argument given to the program;
- # if there is none, python won't crash and the program will move right along.
- try:
- y = sys.argv[1]
- x = sys.argv[2]
- except:
- print("No arguments given, moving right along to prompt statements")
- y = input("y-value in inches? ")
- x = input("x-value in inches? ")
- # turn x and y variables from strings to numbers. is(annoying) == True
- x = float(x)
- y = float(y)
- # convert x from inches to centimeters
- x *= 2.54
- y *= 2.54
- print(x,y)
- area = 0.25 * 0.25
- print(area)
- # since it's a midpoint sum, we have to find the midpoint of the x and y values
- # to plug in to the function.
- point_x = (x/2.54 - 0.125)*2.54
- point_y = (y/2.54 - 0.125)*2.54
- print(point_x)
- print(point_y)
- # note that the ^ operator in the programming world shifts bytes, so ** is
- # used instead.
- z = 14.5161 * (1 - (point_x**2) / 116.532025 - (point_y**2) / 32.661225)
- print(z)
- volume = area * z
- print("The volume in centimeters cubed is: " + str(volume))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement