Ad

I need to memorise some terimnology and definitions so..a comphrehensive(?) dictionary for that. I'll do more later.

# I tried adding as many as I could.
dict_math = {
    "variable":"A symbol (usually a letter) that represents an changeble unknown value",
    "proof":"A logical argument that establishes the truth of a mathematical statement.",
    "axiom":"A self-evident truth or statement that is accepted without proof.",
    "theorem":"A proven mathematical statement based on axioms and previously proven theorems",
    "absolute value": "The distance of a number from zero, regardless of being positive or negative.",
    "binomial": "An expression with two terms.",
    "binomial theorem": "A formula for expanding a binomial expression raised to a power.",
    "coefficient": "A numerical factor multiplied by a variable in a term.",
    "constant": "A number that does not change its value.",
    "domain": "The set of all possible input values for a function.",
    "equation":"A statement that two expressions are equal.",
    "equivalent equations": "Equations that have the same solutions",
    "exponent": "A small number written above and to the right of a base, indicating the number of times the base is multiplied by itself.",
    "expression": "A combination of numbers, variables, and operations.",
    "factor": "A number or expression that divides evenly into another number or expression.",
    "factorial": "The product of all positive integers less than or equal to a given number (denoted by n!).",
    "function": "A rule that assigns a unique output (y-value) to each input (x-value).",
    "inequality": "A statement comparing two expressions using symbols like <, >, ≤, or ≥.",                                                                                                    
    "linear equation": "An equation where the highest power of the variable is 1.",
    "logarithm": "The exponent to which a base number must be raised to get another number. (Inverse of exponentiation)",
    "matrix": "A rectangular array of numbers, symbols, or expressions arranged in rows and columns.",
    "monomial":"An expression with only one term.",
    "polynomial":"An expression with one or more variables raised to non-negative integer powers. (Can be binomial, trinomial, etc.)",
    "quadratic equation":"An equation of the form ax^2 + bx + c = 0, where a ≠ 0.",
    "range":"The set of all possible output values for a function.",
    "rational expression":"An expression where the numerator and denominator are polynomials.",
    "sequence":"An ordered list of numbers.",
    "series":"The sum of the terms in a sequence.",
    "term":"A single number, variable, or combination of them within an expression.",
    "hypotenuse":"The side opposite the right angle in a right triangle.",
    "inscribed angle":"An angle formed inside a circle where both sides intersect the circle.",
    "isosceles triangle":"A triangle with two sides of equal length",
    "parallelogram":"A quadrilateral with both pairs of opposite sides parallel and congruent."

}

def dictionary_math(user_input):
        return dict_math[user_input]

Triangles but it's a class now..It solves the following problems:

  1. Determines third angle (with 2 angles)
  2. Determines the type of triangle with angles (Acute, Obtuse and Right)
  3. Determines the type of triangle with sides (Scalene, Isoceles, Equilateral)

I destroyed it once by reloading it (without saving) 🤦

Code
Diff
  • class Triangle:
        def __init__(a, b, c, s1, s2, s3):
            self.a = a
            self.b = b
            self.c = c 
            self.s1 = s1
            self.s2 = s2
            self.s3 = s3
    
        def other_angle(a, b): 
            return 180 - (a + b)
        
        def triangle_type_angle(a, b, c):
            if all( angle < 90 for angle in (a, b ,c)):
                return "Acute Triangle"
            if any(angle == 90 for angle in (a, b, c)):
                return "Right Triangle"
            return "Obtuse Triangle"
        
        def triangle_type_sides(s1, s2, s3):
            if s1 == s2 == s3:
                return "Equilateral Triangle"
            elif s1 == s2 or s2 == s3 or s1 == s3:
                return "Isoceles Triangle"
            return "Scalene Triangle"
            
    
    • def other_angle(a, b): return 180 - (a + b)
    • class Triangle:
    • def __init__(a, b, c, s1, s2, s3):
    • self.a = a
    • self.b = b
    • self.c = c
    • self.s1 = s1
    • self.s2 = s2
    • self.s3 = s3
    • def other_angle(a, b):
    • return 180 - (a + b)
    • def triangle_type_angle(a, b, c):
    • if all( angle < 90 for angle in (a, b ,c)):
    • return "Acute Triangle"
    • if any(angle == 90 for angle in (a, b, c)):
    • return "Right Triangle"
    • return "Obtuse Triangle"
    • def triangle_type_sides(s1, s2, s3):
    • if s1 == s2 == s3:
    • return "Equilateral Triangle"
    • elif s1 == s2 or s2 == s3 or s1 == s3:
    • return "Isoceles Triangle"
    • return "Scalene Triangle"

Translation to Python??

Code
Diff
  • def other_angle(a, b):
        req_angle = 180 - (a + b)
        return req_angle
    
    
    • fn other_angle(a: u32, b: u32) -> u32 {
    • 180 - (a + b)
    • }
    • def other_angle(a, b):
    • req_angle = 180 - (a + b)
    • return req_angle