y = 5
for x in range(20):
print "x = %d y = %d" %(x, y)
assert(x < y)
import time
import datetime
import math
calendar_start = datetime.datetime.now()
cpu_start = time.time()
count = 0
iterations = 1000000
answer = 'y'
x = 0.0
print "Initial clock time = ", cpu_start, " Initial calendar time = ", calendar_start
while(answer.lower() == 'y'):
for i in range(iterations):
x = math.sqrt(3.14159265)
count += 1
print "%d square roots completed.\n" %(iterations*count)
print "Do you want to run some more(y or n)? "
answer = raw_input()
cpu_end = time.time()
calendar_end = datetime.datetime.now()
print "Final clock time = ", cpu_end, " Final calendar time = ", calendar_end
print "CPU time for %d iterations is %.2f seconds" %(count*iterations, (float(cpu_end-cpu_start)/time.clock()))
print "Elapsed calendar time to execute the program is", calendar_end-calendar_start, " seconds"
from datetime import *
import time
day = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
month = ["January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December"]
now = datetime.now()
suffix = ""
today = day[datetime.today().weekday()]
curr_month = month[now.month-1]
if now.day == 1 or now.day == 21 or now.day == 31:
suffix= "st"
elif now.day == 2 or now.day == 22:
suffix= "nd"
elif now.day == 3 or now.day == 23:
suffix = "rd"
else:
suffix= "th"
print "Today is ", today, " the ",str(now.day)+suffix, curr_month, str(now.year)+".", "The time is ", time.strftime("%H:%M:%S")
from datetime import *
import time
day = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
month = ["January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December"]
now = datetime.now()
suffix = ""
curr_month = month[now.month-1]
print "Enter a name: ",
name = raw_input()
print "Enter a DOB for ", name
dob_day = int(raw_input("Day: "))
dob_month = int(raw_input("Month: "))
dob_year = int(raw_input("Year: "))
dob_date = date(dob_year, dob_month, dob_day)
if dob_day == 1 or dob_day == 21 or dob_day == 31:
suffix= "st"
elif dob_day == 2 or dob_day == 22:
suffix= "nd"
elif dob_day == 3 or dob_day == 23:
suffix = "rd"
else:
suffix= "th"
dob_month = month[dob_month-1]
print name, "Was born on ", str(dob_day)+suffix, dob_month, dob_year, "which was a ", day[date.weekday(dob_date)]