mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2026-06-02 05:18:11 +02:00
Added some physics and computer science questions
This commit is contained in:
Binary file not shown.
@@ -1,7 +1,6 @@
|
|||||||
# mathgenerator
|
# mathgenerator
|
||||||
|
Fork of <https://github.com/lukew3/mathgenerator><br/>
|
||||||
> [!WARNING]
|
Adding more Physics and Computer Science questions<br/>
|
||||||
> I (lukew3), am no longer interested in maintaining this project. If you have a use case for this project and have the abilities to grow it and ensure/improve it's quality, email me at lukew25073@gmail.com and I will consider adding you as a maintainer. Thanks!
|
|
||||||
|
|
||||||
A math problem generator, created for the purpose of giving teachers and students the means to easily get access to random math exercises to suit their needs.
|
A math problem generator, created for the purpose of giving teachers and students the means to easily get access to random math exercises to suit their needs.
|
||||||
|
|
||||||
|
|||||||
+40
-36
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+964
-962
File diff suppressed because one or more lines are too long
+324
-324
File diff suppressed because one or more lines are too long
+191
-189
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1099
-1030
File diff suppressed because one or more lines are too long
+692
-620
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
@@ -8,6 +8,7 @@ from .calculus import *
|
|||||||
from .computer_science import *
|
from .computer_science import *
|
||||||
from .geometry import *
|
from .geometry import *
|
||||||
from .misc import *
|
from .misc import *
|
||||||
|
from .physics import *
|
||||||
from .statistics import *
|
from .statistics import *
|
||||||
|
|
||||||
from ._gen_list import gen_list
|
from ._gen_list import gen_list
|
||||||
|
|||||||
@@ -132,4 +132,6 @@ gen_list = [
|
|||||||
("tribonacci_series", "computer_science"),
|
("tribonacci_series", "computer_science"),
|
||||||
("nth_tribonacci_number", "computer_science"),
|
("nth_tribonacci_number", "computer_science"),
|
||||||
("velocity_of_object", "misc"),
|
("velocity_of_object", "misc"),
|
||||||
|
("binary_addition", "computer_science"),
|
||||||
|
("kinetic_energy", "physics"),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,6 +1,22 @@
|
|||||||
import random
|
import random
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
def binary_addition(max_sum=256, max_addend=128):
|
||||||
|
r"""Binary Addition
|
||||||
|
|
||||||
|
| Ex. Problem | Ex. Solution |
|
||||||
|
| --- | --- |
|
||||||
|
| In binary, calculate: $101 + 110110 = $ | $111011$ |
|
||||||
|
"""
|
||||||
|
if max_addend > max_sum:
|
||||||
|
max_addend = max_sum
|
||||||
|
a = random.randint(0, max_addend)
|
||||||
|
b = random.randint(0, min((max_sum - a), max_addend))
|
||||||
|
c = a + b
|
||||||
|
|
||||||
|
problem = f"In base 2, ${bin(a).replace('0b', "")} + {bin(b).replace('0b', "")} =$ "
|
||||||
|
solution = f'${bin(c).replace('0b', "")}$'
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
def bcd_to_decimal(max_number=10000):
|
def bcd_to_decimal(max_number=10000):
|
||||||
r"""Binary Coded Decimal to Integer
|
r"""Binary Coded Decimal to Integer
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import random
|
||||||
|
import math
|
||||||
|
|
||||||
|
def kinetic_energy(max_mass=1000, max_vel=100):
|
||||||
|
r"""Kinetic Energy calculation using Ek = 0.5 * m * v^2
|
||||||
|
|
||||||
|
| Ex. Problem | Ex. Solution |
|
||||||
|
| --- | --- |
|
||||||
|
| What is the kinetic energy of an object of mass $5 kg$ and velocity $10 m/s$ | $250 J$ |
|
||||||
|
"""
|
||||||
|
velocity = round(random.uniform(1, max_vel),2)
|
||||||
|
mass = round(random.uniform(1, max_mass),2)
|
||||||
|
kinetic_energy = round((0.5 * mass * velocity**2), 2)
|
||||||
|
|
||||||
|
|
||||||
|
problem = f"What is the kinetic energy of an object of mass ${mass} kg$ and velocity ${velocity} m/s$?"
|
||||||
|
solution = f'${kinetic_energy} J$'
|
||||||
|
return problem, solution
|
||||||
Reference in New Issue
Block a user