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}')
Are there any code examples left?
New code examples in category Python
-
Python 2023-04-11 03:04:20
-
Python 2022-03-27 22:40:04 pycharm no module named
-
Python 2022-03-27 22:25:05 assign multiple variablesin one line
-
Python 2022-03-27 22:20:02 levenshtein distance
-
Python 2022-03-27 21:35:09 get text from url python last slash
-
Python 2022-03-27 21:30:30 df concatenate df
-
Python 2022-03-27 21:25:09 python odd or even
-
Python 2022-03-27 21:15:32 python include function from another file
-
Python 2022-03-27 21:10:01 color module python
-
Python 2022-03-27 21:00:27 python tkinter cursor types