python math sheet

Solutions on MaxInterview for python math sheet by the best coders in the world

showing results for - "python math sheet"
Allison
01 May 2017
1import time, random, numpy as np
2
3'''note: this is before i leanred the round(num,prec)
4                                                 ^
5'''
6
7def space():
8  '''spaceing'''
9  time.sleep(0.2)
10  print('')
11  time.sleep(0.2)
12
13class test:    
14  def fract():
15    '''fraction test'''
16    num = random.randint(1, 6)
17    if num == 1:
18      user = float(input('what is 1/3 decimals = 3: '))
19      if (np.around(1/3, decimals=3)) == user:
20        print('yes 1/3 = 0.333 or 0.33 and 1/3')
21      else:
22        print('no 1/3 = 0.333 or .33 and 1/3')
23    elif num == 2:
24      user = float(input('what is 2/3, decimals = 3: '))
25      if (np.around(2/3, decimals=3)) == user:
26        print('yes 2/3 = 0.666 or 0.66 and 2/3')
27      else:
28        print('no 2/3 = 0.666 or 0.66 and 2/3')
29    elif num == 3:
30      user = float(input('what is 1/8, decimals = 3: '))
31      if (np.around(1/8, decimals=3)) == user:
32        print('yes 1/8 = 0.125 or 0.12 and 1/2')
33      else:
34        print('no 2/3 = 0.125 or 0.12 and 1/2')
35    elif num == 4:
36      user = float(input('what is 3/8, decimals = 3: '))
37      if (np.around(3/8, decimals=3)) == user:
38        print('yes 3/8 = 0.375 or 0.37 and 1/2')
39      else:
40        print('no 3/8 = 0.375 or 0.37 and 1/2')
41    elif num == 5:
42      user = float(input('what is 5/8, decimals = 3: '))
43      if (np.around(5/8, decimals=3)) == user:
44        print('yes 5/8 = 0.625 or 0.62 and 1/2')
45      else:
46        print('no 5/8 = 0.625 or 0.62 and 1/2')
47    elif num == 6:
48      user = float(input('what is 7/8, decimals = 3: '))
49      if (np.around(7/8, decimals=3)) == user:
50        print('yes 3/8 = 0.875 or 0.87 and 1/2')
51      else:
52        print('no 5/8 = 0.875 or 0.87 and 1/2')
53  def div(a, b):
54    correct = a/b
55    user = int(input(f'what is {a} / {b}: '))
56    if user == correct:
57      print(f'yes {a} / {b} = {correct}')
58    else:
59      print(f'no {a} / {b} = {correct}')
60  def mul(a, b):
61    anc = a*b
62    user = int(input(f'{a} * {b} = : '))
63    if user == a*b:
64      print(f'correct {a} * {b} = {a*b}')
65    else:
66      print(f'not corect {a} * {b} = {a*b}')
67