from graphics import *
def isLeapYear(year):
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
else:
return True
else:
return False
def daysInMonth(month, year):
if month == 4 or month == 6 or month == 9 or month == 11:
return 30
elif month == 2:
if isLeapYear(year):
return 29
else:
return 28
else:
return 31
# Note below the \ below - this allows a long statement or condition
# to be broken over two lines. Delete this function once you understand
# how it works.
def overlyComplexDaysInMonth(month, year):
if month == 1 or month == 3 or month == 5 or month == 7 or \
month == 8 or month == 10 or month == 12:
return 31
elif month == 4 or month == 6 or month == 9 or month == 11:
return 30
elif isLeapYear(year):
return 29
else:
return 28
def pizzaOrderPrice():
price=input("Enter price of pizza: ")
if price >= 10:
print "You get free delivery, the total is: ", price
if price<10:
print "The delivery charge is 2 pounds, the total is: ", price+2
def calculateGrade():
grade=input("Enter mark out of 20: ")
if grade>=16:
print "You recieved an A"
elif grade>=12:
print "You recieved a B"
elif grade>=8:
print "You recieved a C"
if grade<8:
print "You recieved a F"
def whatToWear():
temp=input("Enter the temperature: ")
if temp>=20:
print "You should wear a t-shirt"
elif temp>=11:
print "You should wear a pullover"
elif temp<=10:
print "You should wear a coat"
def ticketPrice():
ticketprice=60
journey=input("Enter journey distance in kilometres: ")
age=input("Enter Your age: ")
if age>=60:
return ticketprice+(journey*20)*0.4
elif age<=15:
return ticketprice+(journey*20)*0.4
else:
return ticketprice+(journey*20)
def calculatePay():
hours=input("Enter Hours Worked: ")
if hours<=37:
return hours*10
elif hours>37:
return hours*1.5
def drawRedOrBlueCircle():
center1=input("enter first point of center: ")
center2=input("enter second point of center: ")
radius=input("enter the radius: ")
colour=input("choose red or blue colour: ")
win = GraphWin()
shape = Circle(Point(center1, center2), radius)
shape.setFill(colour)
shape.draw(win)