Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # descriptive_calculator.py ZZZ work in progress ???
- import math
- import webbrowser
- PLANCK_CONSTANT = 6.626176 * (10 ** -34)
- Reduced_PLANCK_CONSTANT = PLANCK_CONSTANT / (2 * math.pi)
- def forMenu(t):
- return int(input(msgFix(t)+'\nEnter selection here >>> '))
- def msgFix(t):
- return t.replace('\t','').replace(' ','')
- def msg(t):
- print msgFix(t)
- def AreaOfTriangle():
- a = float(input("Enter the length of A >>> "))
- b = float(input("Enter the length of B >>> "))
- c = float(input("Enter the length of C >>> "))
- s = (a + b + c) / 2
- print s
- print "The value above is the value of s."
- print math.sqrt(s*(s-a)*(s-b)*(s-c))
- print "The answer above is the area of your triangle."
- def PythagoreanTheroemABtoC():
- print "The Pythagorean Theorem states that: a^2 + b^2 = c^2."
- print "Therefore: c^2 - a^2 = b^2."
- print "Therefore: c^2 - b^2 = a^2."
- a = float(input("Enter the value of A >>> "))
- b = float(input("Enter the value of B >>> "))
- c = math.hypot(a,b)
- def AreaOfRectangle():
- print "The formula for the area of a rectangle is: l * w."
- l = float(input("Enter the value of the length >>> "))
- w = float(input("Enter the value of the width >>> "))
- func4area = l * w
- print func4area
- print "Above is the area for your rectangle."
- def AreaOfSquare():
- print "The formula for a area of a square is: l * l."
- l = float(input("Please enter your square's length >>> "))
- func4area = l * l
- print func4area
- print "Above is the area for your square."
- def AreaOfCube():
- print "The formula for a area of a square is: x * y * z."
- l = float(input("Please enter your square's length >>> "))
- func4area = l * l * l
- print func4area
- print "Above is the area for your square."
- def PerimeterOfRectangle():
- print "The formula for the perimeter for a rectangle is: l + l + w + w."
- print "The formula can also be written like this: (l * 2) + (w * 2)."
- l = float(input("Please enter the length of your rectangle >>> "))
- w = float(input("Please enter the width of your rectangle >>> "))
- func4perimeter = (l * 2) + (w * 2)
- print func4perimeter
- print "Above is the perimeter of your rectangle."
- def PermimeterOfSquare():
- print "The formula for the perimeter of a square is: l * 4."
- print "You could also write the formula as: l + l + l + l."
- a = float(input("Please enter the length of your square >>> "))
- func4perimeter = a * 4
- print func4perimeter
- print "Above is the perimeter of your square."
- def VolumeOfARegCuboid():
- print "The formula for the volume for a cube is: x * y * z."
- a = float(input("Please enter the x length of your regular-cuboid >>> "))
- b = float(input("Please enter the y length of your regular-cuboid >>> "))
- c = float(input("Please enter the z length of your regular-cuboid >>> "))
- func4volume = a * b * c
- print func4volume
- print "Above is the volume for your cube."
- def VolumeOfASphere():
- print "The formula for the volume of a sphere is 4 / 3 * pi * r cubed"
- r = float(input("Please enter the radius of your sphere >>> "))
- func4volume = 4 / 3 * math.pi * r ** 3
- print func4volume
- print "Above is the volume for your sphere."
- def AreaOfATriangle():
- print "The area of a triangle if given height and base is: 1/2 * b * h or b * h / 2"
- a = float(input("Please enter the height of your triangle >>> "))
- b = float(input("Please enter the base of your triangle >>> "))
- func4area = (a * b) / 2
- print func4area
- print "Above is the area for your triangle."
- def VolumeOfAPyramid():
- print "The volume of a pyramid if given height and base is: 1.33333333 * b * h"
- h = float(input("Please enter the height of your pyramid >>> "))
- b = float(input("Please enter the base of your pyramid >>> "))
- func4volume = 1.33333333 * b * h
- print func4volume
- print "Above is the volume for your triangle."
- def VolumeOfACone():
- print "The volume of a cone if given height and base is: (1.0/3) * pi * r * r * h"
- h = float(input("Please enter the height of your cone >>> "))
- r = float(input("Please enter the radius of your cone >>> "))
- func4volume = (1.0/3) * math.pi * r * r * h
- print func4volume
- print "Above is the volume for your cone."
- def AreaOfACone():
- print "The area of a cone if given height and base is: pi * r * (r + l)"
- h = float(input("Please enter the height of your cone >>> "))
- r = float(input("Please enter the radius of your cone >>> "))
- func4area = math.pi * radius * (radius + l)
- print func4area
- print "Above is the area for your cone."
- def AreaOfACircleRadiusOnly():
- print "The formula for the area of a circle is : r squared * pi"
- r = float(input("Enter the value of your radius >>> "))
- funcr = r * r
- math.pi * radius * (radius + l) = math.pi * funcr
- print func4area
- print "Above is the area of your circle. Only round the area to three or two decimal places."
- def AreaOfACircleDiameterOnly():
- a = float(input("Enter the value of your diameter >>> "))
- func4radius = a / 2
- func4area = func4radius * math.pi
- print func4area
- print "Above is the area of your circle. Only round to two or three decimal places."
- def AreaOfCircleCircumferenceOnly():
- a = float(input("Enter the value of your circle's circumference >>> "))
- func4diameter = a / math.pi
- func4radius = func4diameter / 2
- func4area = func4radius * math.pi
- print func4area
- print "Above is the area of your circle. Only round to two or three decimal places."
- def CircumferenceOfACircleDiameterOnly():
- a = float(input("Enter the value of your diameter >>> "))
- func4circumference = a * math.pi
- print func4circumference
- def CircumferenceOfACircleRadiusOnly():
- a = float(input("Enter the value of your radius >>> "))
- func4diameter = a * 2
- func4circumference = func4diameter * math.pi
- print func4circumference
- def CircumferenceOfACircleAreaOnly():
- a = float(input("Enter the value of your area >>> "))
- func4radius = math.sqrt((a/math.pi))
- func4diameter = func4radius * 2
- func4circumference = func4diameter * math.pi
- print func4circumference
- def AnglesOnALine():
- a = float(input("Enter the value of one angle on your line besides the given angle >>> "))
- step1 = a + 90
- step2 = 180 - step1
- print step2
- print "The value above is the value of the x angle."
- def TangentFunction():
- x = float(input("Enter the value of the angle whose tangent you would like to find out >>> "))
- a = math.degrees(math.tan(x))
- print a
- print "Above is the value of the tangent of your chosen angle in degrees."
- def CosineFunction():
- x = float(input("Enter the value of the angle whose cosine you would like to find out >>> "))
- a = math.degrees(math.cos(x))
- print a
- print "Above is the value of the cosine of your chosen angle in degrees."
- def SineFunction():
- x = float(input("Enter the value of the angle whose sine you would like to find out >>> "))
- a = math.degrees(math.sin(x))
- print a
- def RaisingNumbersToAnyPower():
- x = float(input("Enter the value of your number >>> "))
- y = float(input("Enter the value of the power you would like to calculate of that number >>> "))
- a = math.pow(x,y)
- print a
- def LogarithmOfANumber():
- x = float(input("Enter the value of the base you are going to be using >>> "))
- y = float(input("Enter the value of the number you want to find the logarithm of >>> "))
- a = math.log(y,x)
- print a
- def RadianToDegrees():
- x = float(input("Enter the value of your angle in radians"))
- print math.degrees(x)
- print "Above is the value of your angle from radians to degrees."
- def DegreesToRadians():
- x = float(input("Enter the value of your angle in degrees >>> "))
- print math.radians(x)
- print "Above is the value of your angle in radians"
- def EToPowers():
- x = float(input("Enter the value of the power you would like to calculate e to >>> "))
- epow = pow(math.e, x)
- print epow
- def PiToPowers():
- x = float(input("Enter the value of the power you would like to calculate pi to >>> "))
- pipow = pow(math.pi, x)
- print pipow
- def Averages():
- print "This function is going to give you averages."
- divisor = int(input("Enter how many values you have >>> "))
- alpha = [chr(alpha) for alpha in range(ord('A'),ord('Z')+1)]
- ddd = {}
- for z in alpha[:divisor]:
- ddd[z] = float(input("Enter value '"+z+"' >>> "))
- avg = sum(ddd.values()) / divisor
- print avg
- print "Above is the value of your average"
- def ArcTan():
- x = float(input("Enter the value of the angle you would like to calculate the arc tangent of >>> "))
- a = math.degrees(math.atan(x))
- print a
- def ArcCos():
- x = float(input("Enter the value of the angle you would like to calculate the arc cosine of >>> "))
- a = math.degrees(math.acos(x))
- print a
- def ArcSine():
- x = float(input("Enter the value of the angle you would like to calculate the arc sine of >>> "))
- a = math.degres(math.asin(x))
- print a
- def PrimeNumberFinder():
- x = float(input("Enter the value any integer you want >>> "))
- a = 2 ** x - 1
- print str(a) + ". Here is the value of your prime number."
- if (0):
- print "Nice try, troll."
- def Force():
- a = float(input("If acceleration and mass is given, enter 0. If change in momentum is given, enter 1 >>> "))
- if (a == 0):
- Intro = "The force will be calculated using mass and acceleration."
- print Intro
- mass = float(input("Enter the mass of your object >>> "))
- acceleration = float(input("Enter the acceleration of your object >>> "))
- force = mass * acceleration
- print str(force) + " N"
- if (a == 1):
- Intro = "The force will be calculated using change in momentum and time. "
- print Intro
- change_in_momentum = float(input("Enter the change in momentum of your object >>> "))
- time = float(input("Enter the time >>> "))
- force = change_in_momentum / time
- print str(force) + " N"
- def Displacement():
- a = float(input("I you have average velocity enter 0. If you have velocity enter 1. Else enter 2 >>> "))
- if (a == 0):
- print "Your displacement will be calculated using your average velocity and time."
- v_avg = float(input("Enter your average velocity >>> "))
- time = float(input("Enter your time >>> "))
- displacement = v_avg * time
- print str(displacement) + " m"
- if (a == 2):
- print "Your displacement will be calculated using the standard method."
- v_i = float(input("Enter your initial velocity >>> "))
- a = float(input("Enter your constant acceleration >>> "))
- t = float(input("Enter your time >>> "))
- displacement = v_i * t + 1/2 * a * t ** 2
- print str(displacement) + " m"
- if (a == 1):
- v = float(input("Enter your velocity >>> "))
- time = float(input("Enter your time >>> "))
- displacement = v * time
- print str(displacement) + " m"
- def Formula_Sheet():
- webbrowser.open('lol')
- def Gradient():
- delta_y = float(input("Enter your change in y axis value >>> "))
- delta_x = float(input("Enter your change in x axis value >>> "))
- gradient = delta_y / delta_x
- print gradient
- def Integral_power_rule_one_order():
- a = float(input("Enter the highest bound that you are integrating from >>> "))
- b = float(input("Enter the lowest bound that you are integrating from >>> "))
- a_b = ((a ** 3) / 3) - ((b ** 3) / 3)
- print str(a_b) + " units ^ 2"
- def Definitions():
- a = forMenu('''If you would like to know definitions in classical mechanics in one dimension enter 1.
- If you would like to know definitions in thermodynamics enter 2.
- If you would like to know definitions in electricity and magnetism enter 3.
- If you would like to know definitions in waves enter 4.
- If you would like to see the formulas please enter 5.''')
- if(a == 1):
- a = forMenu('''For vectors and scalars enter 1.
- For velocity, acceleration and displacement enter 2.
- For force, momentum, impulse and Newton's laws enter 3.''')
- if(a == 1):
- msg('''Vector and scalars are types of things. In classical mechanics anything that you come across is either a vector or scalar.
- A vector has a direction and a magnitude, a magnitude is size or amount. An example of a vector is velocity. Velocity has a direction and it has a size.
- Vectors are often denoted with an arrow on top or being bold.
- A scalar only has a magnitude. It has no direction. An example of a scalar is speed. It only has a magnitude.''')
- if(a == 2):
- msg('''Velocity is a vector. It has a direction and a magnitude. Velocity is how fast something is traveling in a certain direction.
- When talking about vectors you have to specify which direction you are talking about. People usually use east, west, north and south. Instead you can use the minus and positive sign. You have to specify if minus is up, down, left or right if you chose this notation.
- Acceleration is the rate of change of velocity over a certain period of time. Acceleration can be constant and non constant.
- Displacement is the linear distance in a certain direction. Simply put it is how far you are from your original starting position.
- If velocity is constant then there is no acceleration. If velocity is non constant then there is acceleration present.
- The relations between velocity, acceleration and displacement is expressed in differential calculus. The derivative of displacement is velocity. The second derivative of displacement is acceleration.
- If an object is dropped off from a large height then the air resistance which will act upon it will be affecting it's velocity drastically. If dropped of a small height then it's air resistance is negligible
- The acceleration that objects experience when they are thrown is called the acceleration due to gravity. This acceleration only acts vertically.''')
- if(a == 3):
- msg('''Force is a push, pull or twist. Forces can either be unbalanced or balanced. Balanced forces either result in no motion or constant motion. Unbalanced forces result in non constant motion. An example of a balanced force is a team in tug-of-war who are stationary. Or when a car is moving at a constant speed.
- When a car moves at a constant speed it means all the forces acting upon it are balanced.
- There is a type of force which acts in the opposite direction. It opposes an objects motion. This type of force is called a resistive force. Forces which are resistive forces are: air resistance, friction and water resistance.
- Terminal velocity is when air resistance and the force of gravity are completely balanced. This results in your velocity being constant.
- Air resistance depends on the surface area and the shape of the body.
- Friction is a force that causes heat. Friction can be decreased by applying a lubricant. This way there is less heat so therefore there is less friction.''')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement