Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 3 boxes one for the first number, one for the operator and one for second number. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions

Question

What is market mutliple analysis?

Answered: 1 week ago

Question

4. Label problematic uses of language and their remedies

Answered: 1 week ago