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]
import codewars_test as test
@test.describe("Dict test")
def fixed_tests():
@test.it("test case")
def test_case():
test.assert_equals(dictionary_math("variable"),"A symbol (usually a letter) that represents an changeble unknown value")
test.assert_equals(dictionary_math("binomial"),"An expression with two terms.")
test.assert_equals(dictionary_math("coefficient"),"A numerical factor multiplied by a variable in a term.")
Triangles but it's a class now..It solves the following problems:
- Determines third angle (with 2 angles)
- Determines the type of triangle with angles (Acute, Obtuse and Right)
- Determines the type of triangle with sides (Scalene, Isoceles, Equilateral)
I destroyed it once by reloading it (without saving) 🤦
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"
import codewars_test as test @test.describe("tests") def fixed_tests(): @test.it('test cases 1') def func1_test_cases(): test.assert_equals(Triangle.other_angle(30, 60), 90) test.assert_equals(Triangle.other_angle(60, 60), 60) test.assert_equals(Triangle.other_angle(43, 78), 59) test.assert_equals(Triangle.other_angle(10, 20), 150) test.assert_equals(Triangle.other_angle(110, 30), 40) test.assert_equals(Triangle.other_angle(100, 40), 40) @test.it('test cases 2') def func2_test_cases(): test.assert_equals(Triangle.triangle_type_angle(30, 60, 90), "Right Triangle") test.assert_equals(Triangle.triangle_type_angle(45, 45, 90), "Right Triangle") test.assert_equals(Triangle.triangle_type_angle(10, 80, 90), "Right Triangle") test.assert_equals(Triangle.triangle_type_angle(60, 60, 60), "Acute Triangle") test.assert_equals(Triangle.triangle_type_angle(43, 78, 59), "Acute Triangle") test.assert_equals(Triangle.triangle_type_angle(85, 10, 85), "Acute Triangle") test.assert_equals(Triangle.triangle_type_angle(10, 20, 150), "Obtuse Triangle") test.assert_equals(Triangle.triangle_type_angle(110, 30, 40), "Obtuse Triangle") test.assert_equals(Triangle.triangle_type_angle(100, 40, 40), "Obtuse Triangle") @test.it('test cases 3') def func3_test_cases(): test.assert_equals(Triangle.triangle_type_sides(3, 6, 9), "Scalene Triangle") test.assert_equals(Triangle.triangle_type_sides(4, 4, 9), "Isoceles Triangle") test.assert_equals(Triangle.triangle_type_sides(2, 8, 10), "Scalene Triangle") test.assert_equals(Triangle.triangle_type_sides(6, 6, 6), "Equilateral Triangle") test.assert_equals(Triangle.triangle_type_sides(3, 7, 5), "Scalene Triangle") test.assert_equals(Triangle.triangle_type_sides(8, 6, 8), "Isoceles Triangle") test.assert_equals(Triangle.triangle_type_sides(10, 2, 10), "Isoceles Triangle") test.assert_equals(Triangle.triangle_type_sides(10, 10, 10), "Equilateral Triangle") test.assert_equals(Triangle.triangle_type_sides(4, 4, 4), "Equilateral Triangle")
- import codewars_test as test
- @test.describe("tests")
- def fixed_tests():
@test.it('test cases')def basic_test_cases():test.assert_equals(other_angle(30, 60), 90)test.assert_equals(other_angle(60, 60), 60)test.assert_equals(other_angle(43, 78), 59)test.assert_equals(other_angle(10, 20), 150)test.assert_equals(other_angle(110, 30), 40)test.assert_equals(other_angle(100, 40), 40)- @test.it('test cases 1')
- def func1_test_cases():
- test.assert_equals(Triangle.other_angle(30, 60), 90)
- test.assert_equals(Triangle.other_angle(60, 60), 60)
- test.assert_equals(Triangle.other_angle(43, 78), 59)
- test.assert_equals(Triangle.other_angle(10, 20), 150)
- test.assert_equals(Triangle.other_angle(110, 30), 40)
- test.assert_equals(Triangle.other_angle(100, 40), 40)
- @test.it('test cases 2')
- def func2_test_cases():
- test.assert_equals(Triangle.triangle_type_angle(30, 60, 90), "Right Triangle")
- test.assert_equals(Triangle.triangle_type_angle(45, 45, 90), "Right Triangle")
- test.assert_equals(Triangle.triangle_type_angle(10, 80, 90), "Right Triangle")
- test.assert_equals(Triangle.triangle_type_angle(60, 60, 60), "Acute Triangle")
- test.assert_equals(Triangle.triangle_type_angle(43, 78, 59), "Acute Triangle")
- test.assert_equals(Triangle.triangle_type_angle(85, 10, 85), "Acute Triangle")
- test.assert_equals(Triangle.triangle_type_angle(10, 20, 150), "Obtuse Triangle")
- test.assert_equals(Triangle.triangle_type_angle(110, 30, 40), "Obtuse Triangle")
- test.assert_equals(Triangle.triangle_type_angle(100, 40, 40), "Obtuse Triangle")
- @test.it('test cases 3')
- def func3_test_cases():
- test.assert_equals(Triangle.triangle_type_sides(3, 6, 9), "Scalene Triangle")
- test.assert_equals(Triangle.triangle_type_sides(4, 4, 9), "Isoceles Triangle")
- test.assert_equals(Triangle.triangle_type_sides(2, 8, 10), "Scalene Triangle")
- test.assert_equals(Triangle.triangle_type_sides(6, 6, 6), "Equilateral Triangle")
- test.assert_equals(Triangle.triangle_type_sides(3, 7, 5), "Scalene Triangle")
- test.assert_equals(Triangle.triangle_type_sides(8, 6, 8), "Isoceles Triangle")
- test.assert_equals(Triangle.triangle_type_sides(10, 2, 10), "Isoceles Triangle")
- test.assert_equals(Triangle.triangle_type_sides(10, 10, 10), "Equilateral Triangle")
- test.assert_equals(Triangle.triangle_type_sides(4, 4, 4), "Equilateral Triangle")
Translation to Python??
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
import codewars_test as test @test.describe("tests") def fixed_tests(): @test.it('test cases') def basic_test_cases(): test.assert_equals(other_angle(30, 60), 90) test.assert_equals(other_angle(60, 60), 60) test.assert_equals(other_angle(43, 78), 59) test.assert_equals(other_angle(10, 20), 150) test.assert_equals(other_angle(110, 30), 40) test.assert_equals(other_angle(100, 40), 40)
#[test]fn test() {assert_eq!(other_angle(30, 60), 90);assert_eq!(other_angle(60, 60), 60);assert_eq!(other_angle(43, 78), 59);assert_eq!(other_angle(10, 20), 150);}- import codewars_test as test
- @test.describe("tests")
- def fixed_tests():
- @test.it('test cases')
- def basic_test_cases():
- test.assert_equals(other_angle(30, 60), 90)
- test.assert_equals(other_angle(60, 60), 60)
- test.assert_equals(other_angle(43, 78), 59)
- test.assert_equals(other_angle(10, 20), 150)
- test.assert_equals(other_angle(110, 30), 40)
- test.assert_equals(other_angle(100, 40), 40)