1#1
2https://www.onlinegdb.com/online_python_compiler
3#2
4https://repl.it/languages/python3
1from tkinter import *
2def calculate():
3 temp = int(entry.get())
4 temp = 9/5*temp+32
5 output_label.configure(text = 'Converted: {:.1f}'.format(temp))
6 entry.delete(0,END)
7
8root = Tk()
9message_label = Label(text='Enter a temperature', font=('Verdana', 16))
10output_label = Label(font=('Verdana', 16))
11entry = Entry(font=('Verdana', 16), width=4)
12calc_button = Button(text='Ok', font=('Verdana', 16), command=calculate)
13message_label.grid(row=0, column=0)
14entry.grid(row=0, column=1)
15calc_button.grid(row=0, column=2)
16output_label.grid(row=1, column=0, columnspan=3)
17mainloop()
18
1from tkinter import *
2
3app = Tk()
4app.title("Unit Converter")
5scales = ["Meters","Inches","Foot"]
6
7_from = StringVar()
8from_menu = OptionMenu(app, _from, *scales)
9from_menu.grid(row=0,colomn=0,pady=5)
10
11lbl = Label(app,text = 'Convert to')
12lbl.grid(row=0,colomn=1,pady=5)
13
14to_ =StringVar()
15to_menu = OptionMenu(app,to_,*scales)
16to_menu.grid(row=0,colomn=2,pady=5)
17
18enterLabel = Label(app,text='Enter your length')
19enterLabel.grid(row=1,colomn=0,colomnspan=2,pady=5)
20
21num1 = Entry(app)
22num1.grid(row=1,colomn=2,colomnspan=2,pady=5)
23
24def converter():
25 user_input_type = _from.get()
26 convert_type = to_.get()
27 user_input_number = num1.get()
28
29 if user_input_type == 'Meters' and convert_type == 'Inches':
30 converted_value = user_input_number * 39.37
31 elif user_input_type == 'Meters' and convert_type == 'Foot':
32 converted_value = user_input_number * 3.28
33 elif user_input_type == 'Inches' and convert_type == 'Meters':
34 converted_value = user_input_number / 39.37
35 elif user_input_type == 'Foot' and convert_type == 'Inches':
36 converted_value = user_input_number * 12
37 elif user_input_type == 'Inches' and convert_type == 'Foot':
38 converted_value = user_input_number / 12
39 elif user_input_type == 'Foot' and convert_type == 'Meters':
40 converted_value = user_input_number / 3.28
41 else:
42 converted_value = user_input_number
43
44 output_number_label = Label(app,text = round(converted_value,2),width=10)
45 output_number_label.grid(row=1,colomn=4,pady=5)
46
47
48conversion_button = Button(app,text='convert',command='onverter')
49conversion_button.grid(row='2',colomn='0',pady='5')
50
51app.mainloop()
52
53
54
55
56
57
58
59
1from tkinter import *
2
3app = Tk()
4app.title("Unit Converter")
5scales = ["Meters","Inches","Foot"]
6
7_from = StringVar()
8from_menu = OptionMenu(app, _from, *scales)
9from_menu.grid(row=0,colomn=0,pady=5)
10
11lbl = Label(app,text = 'Convert to')
12lbl.grid(row=0,colomn=1,pady=5)
13
14to_ =StringVar()
15to_menu = OptionMenu(app,to_,*scales)
16to_menu.grid(row=0,colomn=2,pady=5)
17
18enterLabel = Label(app,text='Enter your length')
19enterLabel.grid(row=1,colomn=0,colomnspan=2,pady=5)
20
21num1 = Entry(app)
22num1.grid(row=1,colomn=2,colomnspan=2,pady=5)
23
24## 1 Meter = 39.37 Inches
25## 1 Meter = 3.28 Inches
26## 1 Foot = 12 Inches
27
28def converter():
29 user_input_type = _from.get()
30 convert_type = to_.get()
31 user_input_number = num1.get()
32
33 if user_input_type == 'Meters' and convert_type == 'Inches':
34 converted_value = user_input_number * 39.37
35 elif user_input_type == 'Meters' and convert_type == 'Foot':
36 converted_value = user_input_number * 3.28
37 elif user_input_type == 'Inches' and convert_type == 'Meters':
38 converted_value = user_input_number / 39.37
39 elif user_input_type == 'Foot' and convert_type == 'Inches':
40 converted_value = user_input_number * 12
41 elif user_input_type == 'Inches' and convert_type == 'Foot':
42 converted_value = user_input_number / 12
43 elif user_input_type == 'Foot' and convert_type == 'Meters':
44 converted_value = user_input_number / 3.28
45 else:
46 converted_value = user_input_number
47
48 output_number_label = Label(app,text = round(converted_value,2),width=10)
49 output_number_label.grid(row=1,colomn=4,pady=5)
50
51
52conversion_button = Button(app,text='convert',command='onverter')
53conversion_button.grid(row='2',colomn='0',pady='5')
54
55app.mainloop()
56
57
58
59
60
61
62
63
1from tkinter import *
2
3app = Tk()
4app.title("Unit Converter")
5scales = ["Meters","Inches","Foot"]
6
7_from = StringVar()
8from_menu = OptionMenu(app, _from, *scales)
9from_menu.grid(row=0,colomn=0,pady=5)
10
11lbl = Label(app,text = 'Convert to')
12lbl.grid(row=0,colomn=1,pady=5)
13
14to_ =StringVar()
15to_menu = OptionMenu(app,to_,*scales)
16to_menu.grid(row=0,colomn=2,pady=5)
17
18enterLabel = Label(app,text='Enter your length')
19enterLabel.grid(row=1,colomn=0,colomnspan=2,pady=5)
20
21num1 = Entry(app)
22num1.grid(row=1,colomn=2,colomnspan=2,pady=5)
23
24## 1 Meter = 39.37 Inches
25## 1 Meter = 3.28 Inches
26## 1 Foot = 12 Inches
27
28def converter():
29 user_input_type = _from.get()
30 convert_type = to_.get()
31 user_input_number = num1.get()
32
33 if user_input_type == 'Meters' and convert_type == 'Inches':
34 converted_value = user_input_number * 39.37
35 elif user_input_type == 'Meters' and convert_type == 'Foot':
36 converted_value = user_input_number * 3.28
37 elif user_input_type == 'Inches' and convert_type == 'Meters':
38 converted_value = user_input_number / 39.37
39 elif user_input_type == 'Foot' and convert_type == 'Inches':
40 converted_value = user_input_number * 12
41 elif user_input_type == 'Inches' and convert_type == 'Foot':
42 converted_value = user_input_number / 12
43 elif user_input_type == 'Foot' and convert_type == 'Meters':
44 converted_value = user_input_number / 3.28
45 else:
46 converted_value = user_input_number
47
48 output_number_label = Label(app,text = round(converted_value,2),width=10)
49 output_number_label.grid(row=1,colomn=4,pady=5)
50
51
52conversion_button = Button(app,text='convert',command='onverter')
53conversion_button.grid(row='2',colomn='0',pady='5')
54
55app.mainloop()
56
57
58
59
60
61
62
63