SPE10117 Foundations in Information Systems


Programming Exercise

  1. Given the following program to draw a simple logo using Canvas widget from tkinter module

    
    from tkinter import Tk, Canvas
    frame=Tk()
    canvas=Canvas(bg='black',height=250,width=300)
    coord=(100, 100, 200, 200)
    canvas.create_arc(coord,start=0,extent=90,fill='white')
    canvas.create_arc(coord,start=90,extent=90,fill='blue')
    canvas.create_arc(coord,start=180,extent=90,fill='white')
    canvas.create_arc(coord,start=270,extent=90,fill='blue')
    canvas.pack()
    frame.mainloop()
    
    The Canvas class supports more than canvas.create_arc() methods to draw arc or pieslice. Other methods include create_line(),create_oval(),create_polygon(), create_rectangle(), and create_text(). Modify the program above to draw a rectangle and print your name with a line drawn underneath.

  2. Using functions included in "triangle" sctipts from lecture, write a a script which prompts user for three points of a triangle, draws the triangle with area and points printed if the points are valid; otherwise, an error message should be printed.

  3. Rewrite the Loan Table program in Lab 5, add input validation to accept only valid loan amount, interest rate, and payment amount i.e. loan amount in the range of 1000 to 100000, interest rate from 0.1 to 100%, and maximum payment number less than 100. For those errors that should rise to the user, create meaningful error messages. Write a test plan and report your testing.

    Upload all python programmes and test report to github after you finished.