コード例 #1
0
import math
from stdutils import prettyFunction, inputAsDict

print("y = ax^2 + bx + c")
vals = inputAsDict(('a','b','c'))

calcs = {'x1': (-vals['b'] + math.sqrt(vals['b']**2 - 4*vals['a']*vals['c']))/(2*vals['a']), 'x2': (-vals['b'] - math.sqrt(vals['b']**2 - 4*vals['a']*vals['c']))/(2*vals['a'])}

print(prettyFunction("({x1},0),({x2},0)", calcs))
コード例 #2
0
import math
from stdutils import prettyFunction, inputAsDict

vals = inputAsDict(('degree', 'minute', 'second', 'arc'))

vals['de'] = vals['degree'] + (vals['minute'] / 60) + (vals['second'] / 3600)
vals['ra'] = vals['de'] / 180
vals['rap'] = vals['ra'] * math.pi
vals['len'] = vals['arc'] / vals['ra']
vals['lenp'] = vals['arc'] / vals['rap']

print('')
print(
    prettyFunction(
        "{degree}{degree}{minute}\"{second}\' = {de}{degree} = {ra}{pi}",
        vals))
print(prettyFunction("Radius = {arc}/{ra}{pi} = {len}/{pi}", vals))
print(prettyFunction("{len}/{pi} {approx} {lenp}", vals))
コード例 #3
0
from stdutils import prettyFunction, inputAsDict

print("Focus: (a,b)")
print("Directrix: y = c")

values = inputAsDict(('a','b','c'))
formatValues = {'a': -values['a'], 'b': values['b']**2-values['c']**2, 'c': 2*(values['b']-values['c'])}

print("The equation of the parabola is:")
print(prettyFunction("y=((x{a&})^2{b&})/{c}",formatValues))
コード例 #4
0
import math
from stdutils import prettyFunction, inputAsDict

vals = inputAsDict(('degree','minute','second','arc'))

vals['de'] = vals['degree'] + (vals['minute']/60) + (vals['second']/3600)
vals['ra'] = vals['de']/180
vals['rap'] = vals['ra']*math.pi
vals['len'] = vals['arc']/vals['ra']
vals['lenp'] = vals['arc']/vals['rap']

print('')
print(prettyFunction("{degree}{degree}{minute}\"{second}\' = {de}{degree} = {ra}{pi}", vals))
print(prettyFunction("Radius = {arc}/{ra}{pi} = {len}/{pi}", vals))
print(prettyFunction("{len}/{pi} {approx} {lenp}", vals))
コード例 #5
0
from stdutils import prettyFunction, inputAsDict

print("y = ax^2+bx+c\n")
values = inputAsDict(('a','b','c'))

computed = {'h': -values['b']/(2*values['a']), 'k': (4*values['a']*values['c']-values['b']**2)/(4*values['a'])}

print("Vertex of parabola:")
print(prettyFunction("({h},{k})", computed))
コード例 #6
0
import math
from stdutils import prettyFunction, inputAsDict

print("y = ax^2 + bx + c")
vals = inputAsDict(('a', 'b', 'c'))

calcs = {
    'x1': (-vals['b'] + math.sqrt(vals['b']**2 - 4 * vals['a'] * vals['c'])) /
    (2 * vals['a']),
    'x2': (-vals['b'] - math.sqrt(vals['b']**2 - 4 * vals['a'] * vals['c'])) /
    (2 * vals['a'])
}

print(prettyFunction("({x1},0),({x2},0)", calcs))
コード例 #7
0
# Calculate length of an arc using radius and Degrees Minutes and Seconds angle measurement

import math
from stdutils import prettyFunction, inputAsDict

vals = inputAsDict(('degree', 'minute', 'second', 'radius'))

# Convert DMS to radians
vals['de'] = vals['degree'] + (vals['minute'] / 60) + (vals['second'] / 3600)
vals['ra'] = vals['de'] / 180
# Calculate arc length
vals['len'] = vals['radius'] * vals['r']
# Calculations with pi
vals['rap'] = vals['ra'] * math.pi
vals['lenp'] = vals['rap'] * vals['r']

# Print out values
print('')
print(
    prettyFunction(
        "{degree}{degree}{minute}\"{second}\' = {de}{degree} = {ra}{pi}",
        vals))
print(prettyFunction("Arc length = {ra}{pi} x {radius} = {len}{pi}", vals))
print(prettyFunction("{len}{pi} {approx} {lenp}", vals))
コード例 #8
0
from stdutils import prettyFunction, inputAsDict

print("Focus: (a,b)")
print("Directrix: y = c")

values = inputAsDict(('a', 'b', 'c'))
formatValues = {
    'a': -values['a'],
    'b': values['b']**2 - values['c']**2,
    'c': 2 * (values['b'] - values['c'])
}

print("The equation of the parabola is:")
print(prettyFunction("y=((x{a&})^2{b&})/{c}", formatValues))
コード例 #9
0
import math
from stdutils import prettyFunction, inputAsDict

vals = inputAsDict("SideA","AngleA","AngleB")

vals['rad'] = vals['degrees']/180
vals['radp'] = vals['rad']*math.pi
vals['floatDegrees'] = vals['degrees']

print('')
print(prettyFunction("{floatDegrees}{degree} = {rad}{pi} {approx} {radp}",vals))
コード例 #10
0
# Calculate length of an arc using radius and radian angle measurement
import math
from stdutils import prettyFunction, inputAsDict

vals = inputAsDict(('radians', 'radius'))

# Calculate arc length
vals['len'] = vals['radians'] * vals['radius']
# Calculations with pi
vals['lenp'] = vals['rap'] * vals['radius']
vals['rap'] = vals['radians'] * math.pi

print('')
print(prettyFunction("{len}{pi} = {radians}{pi} x {radius}", vals))
print(prettyFunction("{len}{pi} {approx} {lenp}", vals))
コード例 #11
0
# Calculate length of an arc using radius and Degrees Minutes and Seconds angle measurement

import math
from stdutils import prettyFunction, inputAsDict

vals = inputAsDict(('degree','minute','second','radius'))

# Convert DMS to radians
vals['de'] = vals['degree'] + (vals['minute']/60) + (vals['second']/3600)
vals['ra'] = vals['de']/180
# Calculate arc length
vals['len'] = vals['radius']*vals['r']
# Calculations with pi
vals['rap'] = vals['ra']*math.pi
vals['lenp'] = vals['rap']*vals['r']

# Print out values
print('')
print(prettyFunction("{degree}{degree}{minute}\"{second}\' = {de}{degree} = {ra}{pi}", vals))
print(prettyFunction("Arc length = {ra}{pi} x {radius} = {len}{pi}", vals))
print(prettyFunction("{len}{pi} {approx} {lenp}", vals))
コード例 #12
0
# Calculate length of an arc using radius and degree angle measurement

import math
from stdutils import prettyFunction, inputAsDict

vals = inputAsDict(('d','r'))

# Convert degrees to radians
vals['ra'] = vals['d']/180
# Calculate arc length
vals['len'] = vals['ra']*vals['r']
# Calculations with pi
vals['rap'] = vals['ra']*math.pi
vals['lenp'] = vals['rap']*vals['r']

# Print out values
print('')
print(prettyFunction("Arc Length = ({d}{degree} x {pi}/180) x {r}", vals))
print(prettyFunction("{len}{pi} = {ra}{pi} x {r}", vals))
print(prettyFunction("{len}{pi} {approx} {lenp}", vals))
コード例 #13
0
import math
from stdutils import prettyFunction, inputAsDict

vals = inputAsDict(('radians','arc'))

vals['rap'] = vals['radians']*math.pi
vals['len'] = vals['arc']/vals['ra']
vals['lenp'] = vals['arc']/vals['rap']

print('')
print(prettyFunction("Radius = {arc}/{radians}{pi} = {len}/{pi}", vals))
print(prettyFunction("{len}/{pi} {approx} {lenp}", vals))
コード例 #14
0
import math
from stdutils import prettyFunction, inputAsDict

vals = inputAsDict(('degree','arc'))

vals['ra'] = vals['degree']/180
vals['rap'] = vals['ra']*math.pi
vals['len'] = vals['arc']/vals['ra']
vals['lenp'] = vals['arc']/vals['rap']

print('')
print(prettyFunction("Radius = {arc}/({degree}{degree} x {pi} / 180)", vals))
print(prettyFunction("Radius = {arc}/{ra}{pi} = {len}/{pi}", vals))
print(prettyFunction("{len}/{pi} {approx} {lenp}", vals))
コード例 #15
0
from stdutils import prettyFunction, inputAsDict

print("y = ax^2+bx+c\n")
values = inputAsDict(('a', 'b', 'c'))

computed = {
    'h': -values['b'] / (2 * values['a']),
    'k': (4 * values['a'] * values['c'] - values['b']**2) / (4 * values['a'])
}

print("Vertex of parabola:")
print(prettyFunction("({h},{k})", computed))
コード例 #16
0
import math
from stdutils import prettyFunction, inputAsDict

vals = inputAsDict("SideA", "AngleA", "AngleB")

vals['rad'] = vals['degrees'] / 180
vals['radp'] = vals['rad'] * math.pi
vals['floatDegrees'] = vals['degrees']

print('')
print(
    prettyFunction("{floatDegrees}{degree} = {rad}{pi} {approx} {radp}", vals))