Question: How would I create a GUI using tkinter in python with this code. It's a simple calculator using roman numerals instead of arabic numbers. I

How would I create a GUI using tkinter in python with this code. It's a simple calculator using roman numerals instead of arabic numbers. I would like a GUI with 4 boxes one for the first number, one for the operator, one for second number and one for the answer. Also a button that does the equals if possible.

This is the code I have:

def roman_Int(roman_input): ##using dictionary to store corresponding integer value to each roman roman_dict = {'IV':4,'IX':9,'XL':40,'XC':90,'CD':400,'CM':900,'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000} i = 0 ans = 0 ##calculating ans while i < len(roman_input): if i+1

def int_Roman(input_int): roman_smbls = ["M", "CM", "D", "CD","C", "XC", "L", "XL","X", "IX", "V", "IV","I"] values = [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1] i = 0 ans = '' while input_int > 0: for _ in range(input_int // values[i]): ans += roman_smbls[i] input_int -= values[i] i += 1 return ans

ch num1 = input("Enter the 1st number: ") operator = input("Enter an operator (+ - * /): ") num2 = input("Enter the 2nd number: ")

if operator == "+": result = int_Roman(roman_Int(num1) + roman_Int(num2)) print(result) elif operator == "-": result = int_Roman(roman_Int(num1) - roman_Int(num2)) print(result) elif operator == "*": result = int_Roman(roman_Int(num1) * roman_Int(num2)) print(result) elif operator == "/": result = int_Roman(roman_Int(num1) // roman_Int(num2)) print(result) else: print(f"{operator} is not a valid operator")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!