Showing posts with label Pythagoras. Show all posts
Showing posts with label Pythagoras. Show all posts

Python | Maths :'(

/ 9 Aug 2013 /
I made two things today (ikr)

Random math quiz:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from random import *
while 1:
    x = randint(1, 101)
    y = randint(1, 101)
    c = x + y
    ask = input('{} + {} = '.format(x, y))
    if int(ask) == c:
        print('Correct!')
    else:
        print('Wrong!')

Pythagorus solver GUI:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from tkinter import *
from random import *
from math import *

py = Tk()
py.title('Pythagorus')
py.geometry('600x400')
ment = IntVar()
ment1 = IntVar()

def pyth():
    x = ment.get()
    y = ment1.get()
    a = x**2 + y**2
    b = sqrt(a)
    label = Label(py, text = b).place(x=1, y=140)


button = Button(py, text='New Question', command = pyth).place(x=20, y=1)
label_o = Label(py, text='x').place(x=1, y=40)
label_t = Label(py, text='y').place(x=1, y=90)
entry_1 = Entry(textvariable = ment).place(x=20, y=40)
entry_2 = Entry(textvariable = ment1).place(x=20, y=90)


py.mainloop()

Python | Trigonometry

/ 29 Jul 2013 /
So we're FINALLY learning trigo, so I thought to myself, why not make an app about it (I NEED TO STOP THAT)
'Pen-itrator' Ikr

here is the wonderful code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
from tkinter import *
from math import *


def test():
    OPP = ment.get()
    HYP = ment1.get()
    ADJ = ment2.get()
    Sin = OPP + '/' + HYP
    Cos = ADJ + '/' + HYP
    Tan = OPP + '/' + ADJ
    mlabel['text'] = 'sin = ' + Sin
    mlabel1['text'] = 'cos = ' + Cos
    mlabel2['text'] = 'tan = ' + Tan

app = Tk()
app.title('Pen-itrator')
app.geometry('800x600')


#Variables
ment = StringVar()
ment1 = StringVar()
ment2 = StringVar()

#Button
mbutton = Button(app, text = 'SIN!', command = test)
mbutton.place(x=5, y=7.5)
#Label
mlabel = Label(app, text='')
mlabel.place(x=5, y=35)
mlabel1 = Label(app, text='')
mlabel1.place(x=5, y=65)
mlabel2 = Label(app, text='')
mlabel2.place(x=5, y=95)
#More Labels
nlabel = Label(app, text= 'Opposite side')
nlabel.place(x=65, y=7.5)
nlabel1 = Label(app, text= 'Hypotenuse')
nlabel1.place(x=65, y=57.5)
nlabel2 = Label(app, text= 'Adjacent side')
nlabel2.place(x=65, y=107.5)
#Entry
opp = Entry(textvariable=ment).place(x=150, y=7.5)
hyp = Entry(textvariable=ment1).place(x=150, y=57.5)
adj = Entry(textvariable=ment2).place(x=150, y=107.5)


app.mainloop()

Python | Pythagoras Calculator

/ 7 Jul 2013 /
This is the first python program I built using nothing but my knowledge, (and code..duh). It's not very complex, at all.. but it got me to a start.


1
2
3
4
5
6
7
8
9
import math

while 1:
     a = int(input("Please enter the value of a: "))
     b = int(input("Please enter the value of b: "))
     c = math.sqrt(a**2 + b**2)
     print("Thank you for using my pythagorus calculator!")
     print("Your answer is: ", c)
     print("Want to try again?…")
 
Copyright © 2010 M(ath)+me, All rights reserved