python math i code example
Example: python math sheet
import time, random, numpy as np
'''note: this is before i leanred the round(num,prec)
^
'''
def space():
'''spaceing'''
time.sleep(0.2)
print('')
time.sleep(0.2)
class test:
def fract():
'''fraction test'''
num = random.randint(1, 6)
if num == 1:
user = float(input('what is 1/3 decimals = 3: '))
if (np.around(1/3, decimals=3)) == user:
print('yes 1/3 = 0.333 or 0.33 and 1/3')
else:
print('no 1/3 = 0.333 or .33 and 1/3')
elif num == 2:
user = float(input('what is 2/3, decimals = 3: '))
if (np.around(2/3, decimals=3)) == user:
print('yes 2/3 = 0.666 or 0.66 and 2/3')
else:
print('no 2/3 = 0.666 or 0.66 and 2/3')
elif num == 3:
user = float(input('what is 1/8, decimals = 3: '))
if (np.around(1/8, decimals=3)) == user:
print('yes 1/8 = 0.125 or 0.12 and 1/2')
else:
print('no 2/3 = 0.125 or 0.12 and 1/2')
elif num == 4:
user = float(input('what is 3/8, decimals = 3: '))
if (np.around(3/8, decimals=3)) == user:
print('yes 3/8 = 0.375 or 0.37 and 1/2')
else:
print('no 3/8 = 0.375 or 0.37 and 1/2')
elif num == 5:
user = float(input('what is 5/8, decimals = 3: '))
if (np.around(5/8, decimals=3)) == user:
print('yes 5/8 = 0.625 or 0.62 and 1/2')
else:
print('no 5/8 = 0.625 or 0.62 and 1/2')
elif num == 6:
user = float(input('what is 7/8, decimals = 3: '))
if (np.around(7/8, decimals=3)) == user:
print('yes 3/8 = 0.875 or 0.87 and 1/2')
else:
print('no 5/8 = 0.875 or 0.87 and 1/2')
def div(a, b):
correct = a/b
user = int(input(f'what is {a} / {b}: '))
if user == correct:
print(f'yes {a} / {b} = {correct}')
else:
print(f'no {a} / {b} = {correct}')
def mul(a, b):
anc = a*b
user = int(input(f'{a} * {b} = : '))
if user == a*b:
print(f'correct {a} * {b} = {a*b}')
else:
print(f'not corect {a} * {b} = {a*b}')