### SAMS Senior Non-CS-Track Week3-2 Exercise
### Due Date: Thursday 07/18 2:30pm
### Name:
### andrewID:
from tkinter import *
import math
### Exercise 1 ###
# Write one or more lines of code that interactively asks the user to enter a
# number, then prints out that number rounded to one decimal place.
# For example, if I entered "4.234", it would print 4.2;
# if I entered "6.591", it would print 6.6
### Exercise 2 ###
# Write a function called helloWorld which takes no input and simply prints
# the string "Hello, World!". Then call this function three times at the
# top-level of the code, so that "Hello, World!" is printed three times overall.
### Exercise 3 ###
# Write the function drawCircle(canvas, x, y, r). This function takes four
# parameters – the canvas, an (x,y) coordinate, and an integer r – and uses
# them to draw a circle centered at (x,y) with radius r.
# Then call drawCircle at the top-level of the code with three different
# coordinates (and three different radii) to produce a picture with three
# circles in different locations on the canvas.
width = 400
height = 400
# Don't worry about what the next four lines of code do
root = Tk()
canvas = Canvas(root, width=width, height=height)
canvas.configure(bd=0, highlightthickness=0)
canvas.pack()
# Put your code here!
root.mainloop() # this tells the window to stay open until we close it
### Exercise 4 ###
# Write the function circlePerimeter(r) which takes a radius (r) and returns
# the perimeter of a circle with that radius. Recall that we calculate a
# circle's perimeter with 2πr. (You can use math.pi to get the value of π).
# Then, at the top level of the code, write a line of code that prints the
# perimeter of a semicircle with a radius of 20. You must call your
# circlePerimeter() function to get full credit!
### Exercise 5 ###
# Write the function trianglePerimeter(x1, y1, x2, y2, x3, y3) which takes
# three coordinates – (x1, y1), (x2, y2), and (x3, y3) – and calculates the
# perimeter of the triangle made by connecting those three points.
# To make solving this problem easier, you should also write the function
# distance(x1, y1, x2, y2) which takes two coordinates –
# (x1, y1) and (x2, y2) – and calculates the distance between them. You should
# then call distance() from trianglePerimeter().
# Finally, print out the result of calling trianglePerimeter on the points
# (0, 50), (20, 30), and (70, 80) to find the perimeter of that triangle!