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() |