Advertisement
here2share

# descriptive_calculator.py

Jul 13th, 2020
1,151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 13.03 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # descriptive_calculator.py ZZZ work in progress ???
  4.  
  5. import math
  6. import webbrowser
  7.  
  8. PLANCK_CONSTANT = 6.626176 * (10 ** -34)
  9. Reduced_PLANCK_CONSTANT = PLANCK_CONSTANT / (2 * math.pi)
  10.  
  11. def forMenu(t):
  12.     return int(input(msgFix(t)+'\nEnter selection here >>> '))
  13.  
  14. def msgFix(t):
  15.     return t.replace('\t','').replace('  ','')
  16.  
  17. def msg(t):
  18.     print msgFix(t)
  19.  
  20. def AreaOfTriangle():
  21.     a = float(input("Enter the length of A >>> "))
  22.     b = float(input("Enter the length of B >>> "))
  23.     c = float(input("Enter the length of C >>> "))
  24.     s = (a + b + c) / 2
  25.     print s
  26.     print "The value above is the value of s."
  27.     print math.sqrt(s*(s-a)*(s-b)*(s-c))
  28.     print "The answer above is the area of your triangle."
  29.  
  30. def PythagoreanTheroemABtoC():
  31.     print "The Pythagorean Theorem states that: a^2 + b^2 = c^2."
  32.     print "Therefore: c^2 - a^2 = b^2."
  33.     print "Therefore: c^2 - b^2 = a^2."
  34.     a = float(input("Enter the value of A >>> "))
  35.     b = float(input("Enter the value of B >>> "))
  36.     c = math.hypot(a,b)
  37.  
  38. def AreaOfRectangle():
  39.     print "The formula for the area of a rectangle is: l * w."
  40.     l = float(input("Enter the value of the length >>> "))
  41.     w = float(input("Enter the value of the width >>> "))
  42.     func4area = l * w
  43.     print func4area
  44.     print "Above is the area for your rectangle."
  45.  
  46. def AreaOfSquare():
  47.     print "The formula for a area of a square is: l * l."
  48.     l = float(input("Please enter your square's length >>> "))
  49.     func4area = l * l
  50.     print func4area
  51.     print "Above is the area for your square."
  52.  
  53. def AreaOfCube():
  54.     print "The formula for a area of a square is: x * y * z."
  55.     l = float(input("Please enter your square's length >>> "))
  56.     func4area = l * l * l
  57.     print func4area
  58.     print "Above is the area for your square."
  59.  
  60. def PerimeterOfRectangle():
  61.     print "The formula for the perimeter for a rectangle is: l + l + w + w."
  62.     print "The formula can also be written like this: (l * 2) + (w * 2)."
  63.     l = float(input("Please enter the length of your rectangle >>> "))
  64.     w = float(input("Please enter the width of your rectangle >>> "))
  65.     func4perimeter = (l * 2) + (w * 2)
  66.     print func4perimeter
  67.     print "Above is the perimeter of your rectangle."
  68.  
  69. def PermimeterOfSquare():
  70.     print "The formula for the perimeter of a square is: l * 4."
  71.     print "You could also write the formula as: l + l + l + l."
  72.     a = float(input("Please enter the length of your square >>> "))
  73.     func4perimeter = a * 4
  74.     print func4perimeter
  75.     print "Above is the perimeter of your square."
  76.  
  77. def VolumeOfARegCuboid():
  78.     print "The formula for the volume for a cube is: x * y * z."
  79.     a = float(input("Please enter the x length of your regular-cuboid >>> "))
  80.     b = float(input("Please enter the y length of your regular-cuboid >>> "))
  81.     c = float(input("Please enter the z length of your regular-cuboid >>> "))
  82.     func4volume = a * b * c
  83.     print func4volume
  84.     print "Above is the volume for your cube."
  85.    
  86. def VolumeOfASphere():
  87.     print "The formula for the volume of a sphere is 4 / 3 * pi * r cubed"
  88.     r = float(input("Please enter the radius of your sphere >>> "))
  89.     func4volume = 4 / 3 * math.pi * r ** 3
  90.     print func4volume
  91.     print "Above is the volume for your sphere."
  92.  
  93. def AreaOfATriangle():
  94.     print "The area of a triangle if given height and base is: 1/2 * b * h or b * h / 2"
  95.     a = float(input("Please enter the height of your triangle >>> "))
  96.     b = float(input("Please enter the base of your triangle >>> "))
  97.     func4area = (a * b) / 2
  98.     print func4area
  99.     print "Above is the area for your triangle."
  100.  
  101. def VolumeOfAPyramid():
  102.     print "The volume of a pyramid if given height and base is: 1.33333333 * b * h"
  103.     h = float(input("Please enter the height of your pyramid >>> "))
  104.     b = float(input("Please enter the base of your pyramid >>> "))
  105.     func4volume = 1.33333333 * b * h
  106.     print func4volume
  107.     print "Above is the volume for your triangle."
  108.  
  109. def VolumeOfACone():
  110.     print "The volume of a cone if given height and base is: (1.0/3) * pi * r * r * h"
  111.     h = float(input("Please enter the height of your cone >>> "))
  112.     r = float(input("Please enter the radius of your cone >>> "))
  113.     func4volume = (1.0/3) * math.pi * r * r * h
  114.     print func4volume
  115.     print "Above is the volume for your cone."
  116.  
  117. def AreaOfACone():
  118.     print "The area of a cone if given height and base is: pi * r * (r + l)"
  119.     h = float(input("Please enter the height of your cone >>> "))
  120.     r = float(input("Please enter the radius of your cone >>> "))
  121.     func4area = math.pi * radius * (radius + l)
  122.     print func4area
  123.     print "Above is the area for your cone."
  124.    
  125. def AreaOfACircleRadiusOnly():
  126.     print "The formula for the area of a circle is : r squared * pi"
  127.     r = float(input("Enter the value of your radius >>> "))
  128.     funcr = r * r
  129.     math.pi * radius * (radius + l) = math.pi * funcr
  130.     print func4area
  131.     print "Above is the area of your circle. Only round the area to three or two decimal places."
  132.  
  133. def AreaOfACircleDiameterOnly():
  134.     a = float(input("Enter the value of your diameter >>> "))
  135.     func4radius = a / 2
  136.     func4area = func4radius * math.pi
  137.     print func4area
  138.     print "Above is the area of your circle. Only round to two or three decimal places."
  139.  
  140. def AreaOfCircleCircumferenceOnly():
  141.     a = float(input("Enter the value of your circle's circumference >>> "))
  142.     func4diameter = a / math.pi
  143.     func4radius = func4diameter / 2
  144.     func4area = func4radius * math.pi
  145.     print func4area
  146.     print "Above is the area of your circle. Only round to two or three decimal places."
  147.  
  148. def CircumferenceOfACircleDiameterOnly():
  149.     a = float(input("Enter the value of your diameter >>> "))
  150.     func4circumference = a * math.pi
  151.     print func4circumference
  152.  
  153. def CircumferenceOfACircleRadiusOnly():
  154.     a = float(input("Enter the value of your radius >>> "))
  155.     func4diameter = a * 2
  156.     func4circumference = func4diameter * math.pi
  157.     print func4circumference
  158.  
  159. def CircumferenceOfACircleAreaOnly():
  160.     a = float(input("Enter the value of your area >>> "))
  161.     func4radius = math.sqrt((a/math.pi))
  162.     func4diameter = func4radius * 2
  163.     func4circumference = func4diameter * math.pi
  164.     print func4circumference
  165.  
  166. def AnglesOnALine():
  167.     a = float(input("Enter the value of one angle on your line besides the given angle >>> "))
  168.     step1 = a + 90
  169.     step2 = 180 - step1
  170.     print step2
  171.     print "The value above is the value of the x angle."
  172.  
  173. def TangentFunction():
  174.     x = float(input("Enter the value of the angle whose tangent you would like to find out >>> "))
  175.     a = math.degrees(math.tan(x))
  176.     print a
  177.     print "Above is the value of the tangent of your chosen angle in degrees."
  178.  
  179. def CosineFunction():
  180.     x = float(input("Enter the value of the angle whose cosine you would like to find out >>> "))
  181.     a = math.degrees(math.cos(x))
  182.     print a
  183.     print "Above is the value of the cosine of your chosen angle in degrees."
  184.  
  185. def SineFunction():
  186.     x = float(input("Enter the value of the angle whose sine you would like to find out >>> "))
  187.     a = math.degrees(math.sin(x))
  188.     print a
  189.  
  190. def RaisingNumbersToAnyPower():
  191.     x = float(input("Enter  the value of your number >>> "))
  192.     y = float(input("Enter the value of the power you would like to calculate of that number >>> "))
  193.     a = math.pow(x,y)
  194.     print a
  195.  
  196. def LogarithmOfANumber():
  197.     x = float(input("Enter the value of the base you are going to be using >>> "))
  198.     y = float(input("Enter the value of the number you want to find the logarithm of >>> "))
  199.     a = math.log(y,x)
  200.     print a
  201.  
  202. def RadianToDegrees():
  203.     x = float(input("Enter the value of your angle in radians"))
  204.     print math.degrees(x)
  205.     print "Above is the value of your angle from radians to degrees."
  206.  
  207. def DegreesToRadians():
  208.     x = float(input("Enter the value of your angle in degrees >>> "))
  209.     print math.radians(x)
  210.     print "Above is the value of your angle in radians"
  211.  
  212. def EToPowers():
  213.     x = float(input("Enter the value of the power you would like to calculate e to >>> "))
  214.     epow = pow(math.e, x)
  215.     print epow
  216.  
  217. def PiToPowers():
  218.     x = float(input("Enter the value of the power you would like to calculate pi to >>> "))
  219.     pipow = pow(math.pi, x)
  220.     print pipow
  221.  
  222. def Averages():
  223.     print "This function is going to give you averages."
  224.     divisor = int(input("Enter how many values you have >>> "))
  225.     alpha = [chr(alpha) for alpha in range(ord('A'),ord('Z')+1)]
  226.     ddd = {}
  227.     for z in alpha[:divisor]:
  228.         ddd[z] = float(input("Enter value '"+z+"' >>> "))
  229.     avg = sum(ddd.values()) / divisor
  230.     print avg
  231.     print "Above is the value of your average"
  232.  
  233. def ArcTan():
  234.     x = float(input("Enter the value of the angle you would like to calculate the arc tangent of >>> "))
  235.     a = math.degrees(math.atan(x))
  236.     print a
  237.  
  238. def ArcCos():
  239.     x = float(input("Enter the value of the angle you would like to calculate the arc cosine of >>> "))
  240.     a = math.degrees(math.acos(x))
  241.     print a
  242.  
  243. def ArcSine():
  244.     x = float(input("Enter the value of the angle you would like to calculate the arc sine of >>> "))
  245.     a = math.degres(math.asin(x))
  246.     print a
  247.  
  248. def PrimeNumberFinder():
  249.     x = float(input("Enter the value any integer you want >>> "))
  250.     a = 2 ** x - 1
  251.     print str(a) + ". Here is the value of your prime number."
  252.     if (0):
  253.         print "Nice try, troll."
  254.  
  255. def Force():
  256.     a = float(input("If acceleration and mass is given, enter 0. If change in momentum is given, enter 1 >>> "))
  257.     if (a == 0):
  258.         Intro = "The force will be calculated using mass and acceleration."
  259.         print Intro
  260.         mass = float(input("Enter the mass of your object >>> "))
  261.         acceleration = float(input("Enter the acceleration of your object >>> "))
  262.         force = mass * acceleration
  263.         print str(force) + " N"
  264.     if (a == 1):
  265.         Intro = "The force will be calculated using change in momentum and time. "
  266.         print Intro
  267.         change_in_momentum = float(input("Enter the change in momentum of your object >>> "))
  268.         time = float(input("Enter the time >>> "))
  269.         force = change_in_momentum / time
  270.         print str(force) + " N"
  271.  
  272. def Displacement():
  273.     a = float(input("I you have average velocity enter 0. If you have velocity enter 1. Else enter 2 >>> "))
  274.     if (a == 0):
  275.         print "Your displacement will be calculated using your average velocity and time."
  276.         v_avg = float(input("Enter your average velocity >>> "))
  277.         time = float(input("Enter your time >>> "))
  278.         displacement  = v_avg * time
  279.         print str(displacement) + " m"
  280.     if (a == 2):
  281.         print "Your displacement will be calculated using the standard method."
  282.         v_i = float(input("Enter your initial velocity >>> "))
  283.         a = float(input("Enter your constant acceleration >>> "))
  284.         t = float(input("Enter your time >>> "))
  285.         displacement = v_i * t + 1/2 * a * t ** 2
  286.         print str(displacement) + " m"
  287.     if (a == 1):
  288.         v  = float(input("Enter your velocity >>> "))
  289.         time = float(input("Enter your time >>> "))
  290.         displacement = v * time
  291.         print str(displacement) + " m"
  292.  
  293. def Formula_Sheet():
  294.     webbrowser.open('lol')
  295.  
  296. def Gradient():
  297.     delta_y = float(input("Enter your change in y axis value >>> "))
  298.     delta_x = float(input("Enter your change in x axis value >>> "))
  299.     gradient = delta_y / delta_x
  300.     print gradient
  301.  
  302. def Integral_power_rule_one_order():
  303.     a = float(input("Enter the highest bound that you are integrating from >>> "))
  304.     b = float(input("Enter the lowest bound that you are integrating from >>> "))
  305.     a_b = ((a ** 3) / 3) - ((b ** 3) / 3)
  306.     print str(a_b) + " units ^ 2"
  307.  
  308. def Definitions():
  309.     a = forMenu('''If you would like to know definitions in classical mechanics in one dimension enter 1.
  310.     If you would like to know definitions in thermodynamics enter 2.
  311.     If you would like to know definitions in electricity and magnetism enter 3.
  312.     If you would like to know definitions in waves enter 4.
  313.     If you would like to see the formulas please enter 5.''')
  314.     if(a == 1):
  315.         a = forMenu('''For vectors and scalars enter 1.
  316.         For velocity, acceleration and displacement enter 2.
  317.         For force, momentum, impulse and Newton's laws enter 3.''')
  318.         if(a == 1):
  319.             msg('''Vector and scalars are types of things. In classical mechanics anything that you come across is either a vector or scalar.
  320.             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.
  321.             Vectors are often denoted with an arrow on top or being bold.
  322.             A scalar only has a magnitude. It has no direction. An example of a scalar is speed. It only has a magnitude.''')
  323.         if(a == 2):
  324.             msg('''Velocity is a vector. It has a direction and a magnitude. Velocity is how fast something is traveling in a certain direction.
  325.             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.
  326.             Acceleration is the rate of change of velocity over a certain period of time. Acceleration can be constant and non constant.
  327.             Displacement is the linear distance in a certain direction. Simply put it is how far you are from your original starting position.
  328.             If velocity is constant then there is no acceleration. If velocity is non constant then there is acceleration present.
  329.             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.
  330.             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
  331.             The acceleration that objects experience when they are thrown is called the acceleration due to gravity. This acceleration only acts vertically.''')
  332.         if(a == 3):
  333.             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.
  334.             When a car moves at a constant speed it means all the forces acting upon it are balanced.
  335.             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.
  336.             Terminal velocity is when air resistance and the force of gravity are completely balanced. This results in your velocity being constant.
  337.             Air resistance depends on the surface area and the shape of the body.
  338.             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