Top Trending Books

Wednesday, November 19, 2014

Python: Find out dates from Last Week.

Following code can be used to findout the Dates of Last week starting from monday
 import time  
 from datetime import date, timedelta  
 def foo(year, week):  
   d = date(year,1,1)  
   d = d - timedelta(d.weekday())  
   dlt = timedelta(days = (week)*7)  
   return d + dlt, d + dlt + timedelta(days=6)  
 print "Current Week Number is :::" + weekNumber  
 print "Current Year is :::" + yearInTest  
 print "Last Week Number is :::" + str(lastWeeknumber)  
 print str(dateInTest)  

Wednesday, November 5, 2014

Python: Python Challenge - Level 1 : Proposed Solution

Second problem on "" is an image which displays the offset of alphabets we should apply in the given string below the image. To solve this, I tried the following Solution:

 uRLStringConstant = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."  
 for i in uRLStringConstant:  
      convertedValue = ord(i) +2  
      if convertedValue > 122:  
           convertedValue = 97  
      if convertedValue == 34:  
           convertedValue = 32  
      if convertedValue == 48:  
           convertedValue = 46  
      convertedCharater = chr(convertedValue)  
 print '[%s]' % ''.join(map(str, listSet))  

Output was:
 Using 'map', we convert it to 'ocr'  
 Hence the URL is