how to multiply 2 decimals together and get answer back in python

Solutions on MaxInterview for how to multiply 2 decimals together and get answer back in python by the best coders in the world

showing results for - "how to multiply 2 decimals together and get answer back in python"
Vincent
08 May 2020
1import kivy # todo import buttons from kivy and add clear number button on bottum of program and then bind button
2from kivy.app import App
3from kivy.uix.label import Label
4from kivy.uix.gridlayout import GridLayout
5from kivy.uix.textinput import TextInput
6from kivy.uix.button import Button
7import math
8
9class MyGrid(GridLayout):
10    def __init__(self, **kwargs):
11        super(MyGrid, self).__init__(**kwargs)
12        self.cols = 1
13
14        self.inside = GridLayout()
15        self.inside.cols = 2
16
17        self.inside.add_widget(Label(text="NUM1: "))
18        self.num1 = TextInput(multiline=False)
19        self.inside.add_widget(self.num1)
20
21        self.inside.add_widget(Label(text="NUM2: "))
22        self.num2 = TextInput(multiline=False)
23        self.inside.add_widget(self.num2)
24
25        self.inside.add_widget(Label(text="ANSWER: "))
26        self.answer = TextInput(multiline=False)
27        self.inside.add_widget(self.answer)
28
29
30        self.add_widget(self.inside)
31        self.clear = Button(text="Clear", font_size=20)
32        self.clear.bind(on_press=self.pressed)
33        self.add_widget(self.clear)
34
35
36    def pressed (self, instance):
37        num1 = self.num1.text
38        num2 = self.num2.text
39        answer = self.answer.text
40
41        print("num1:", num1, "num2:", num2, "answer:", answer)
42
43	 def numbermultiplier(num1, num2):
44      ans = num1 * num2
45      return ans
46    print(numbermultiplier(12700.00,5.63))	
47
48class MyApp(App):
49    def build(self):
50        return MyGrid()
51
52
53if __name__ == "__main__":
54    MyApp().run()
55
56
57# Hi there here is my code ??What I want is to multiply num1 and num2 together in the text box and for it to display the answer in the answer box and if I press clear to clear the whole box 
58
59