# tpm.py
# Take two inputs, age and years of citizenship, and returns eligibility for
# senator and representative.
from graphics import *
def main():
win = GraphWin('Eligibility' , 400,400)
win.setCoords(0.0,0.0, 4.0, 4.0)
Text(Point(1, 3.0), 'Age').draw(win)
Text(Point(1, 2.0), 'Years Citizen').draw(win)
agebox = Entry(Point(2, 3.0), 10)
agebox.draw(win)
citizenshipbox = Entry(Point(2, 2.0), 10)
citizenshipbox.draw(win)
output = Text(Point(2.0, 1.0), 'Eligibility')
output.draw(win)
win.getMouse()
age = eval(agebox.getText())
citizenship = eval(citizenshipbox.getText())
if 30 > age >= 25:
if citizenship >= 7:
output.setText('Eligible for US representative')
else:
output.setText('Ineligible for US representative')
elif age >= 30:
if citizenship >= 9:
output.setText('Eligible for US senator and US representative')
elif 9 > citizenship >= 7:
output.setText('Ineligible for US senator, eligible for US representative')
else:
output.setText('Ineligible for US senator or representative')
win.getMouse()
win.close()
main()
:o
Edit: Added code tags, see http://www.daniweb.com/techtalkforums/announcement114-3.html