Skip to main content

Damn

Project description

damn

damn (desperately agonizing math noobs) is a language to help you write knowledge assessment test generators.

Language will help you in variables constraints declaration and generate unique pairs of data. Then, the generated pair of variables can be evaluated with the formula (via wolframalpha integration).

Syntax:

1 > x > 10
y in [1, 2, 3]
(a, b) in [(4, 5), (1, 10)]

Example

Constraints:

10 > a > 20
(v1, v2) in [(1, 2), (4, 8)]

Formula:

a = (v2 - v1)/t

Making a test:

from damn import DefinitionSet, Calculator
import asyncio

calculator = Calculator(["DEMO"])

async def main():
    def_set = DefinitionSet.from_expressions([
        "10 > a > 20", 
        "(v1, v2) in [(1, 2), (4, 8)]"
    ])
    data = def_set.get_data()
    print(
        "What is delta t if " + 
        ", ".join(
            (f"{k} = {v.get_common_representation()}" for k, v in data.items())
        )
    )
    result = await calculator.calculate(data, "a = (v2 - v1)/t")
    answer = float(input("your answer > "))
    if answer == result.v:
        print("great!!")
        return
    print(f"BAD student. the right answer is {result.v}")

asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

damnlang-0.1.0.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

damnlang-0.1.0-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page