Tuesday, February 2, 2016

#PythonTuesday #Coding --- Importing a built-in module


A simple way to import a built-in module in the Python!
  1. import datetime
  2. import calendar
  3.  
  4.  
  5. cal = calendar.month(2016,2)
  6. print "Time is flying!!"
  7. print "**********************"
  8. print cal
  9. print "**********************"
  10.  
  11. today = datetime.date.today()
  12. print "Today is", today
  13. print "Make everyday count!"
  14. #ending 


Output:

Time is flying!!
**********************
   February 2016
Mo Tu We Th Fr Sa Su
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29

**********************
Today is 2016-02-02
Make everyday count!

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

CodeCombat !  Screenshot of "A_Mayhem_of_Munchkins":


Goals:

  • Your hero must survive.
  • Under 4 statements
Code:

while True:
        enemy = self.findNearestEnemy()
        self.attack(enemy)
        self.attack(enemy)


No comments:

Post a Comment