[Tutor] How do we create a GUI to run a simple calculation program in Python?
Lisa Hasler Waters
lwaters at flinthill.org
Tue Apr 4 12:55:27 EDT 2017
Hello Tutor,
A middle school student of mine created a program to calculate simple and
compound interest. He built it in PyCharm EDU using a Mac running 10.11.6.
He would like to create a GUI to run this program. Please, can you advise
on how he could build this?
Here is his code:
def simple(m, t, r):
r = r/100
print("The interest is {} and the total is {} ".format(r*m*t, m+r*m*t))
def compound(m, t, r):
morg = m
r = r/100
for x in range(0, t):
m = m*r+m
print("The interest is {} and the total is {} if compounded
yearly.".format(m-morg, m))
m = morg
r = r/12
for x in range(0, t*12):
m = m*r+m
print("The interest is {} and the total is {} if compounded
monthly.".format(m-morg, m))
choice = str(input("Would you like to use simple or compound interest? "))
m = int(input("Input the amount of money you would like to deposit
(don't use the $ symbol): "))
t = int(input("Input the amount of time you will be keeping your money
in the bank (in years): "))
r = int(input("Input the interest rate the bank offers (don't use the
% symbol): "))
if choice == 'simple':
simple(m, t, r)
elif choice == 'compound':
compound(m, t, r)
else:
print("Your input is invalid")
Many thanks,
Lisa Waters
--
Lisa Waters, PhD
Technology Integration
Middle School Coding
Lower School Digital Literacy
Flint Hill School
703.584.2300
*www.flinthill.org* <http://www.flinthill.org/>
More information about the Tutor
mailing list