You may also create your own modules for your own projects. This is an example of a module created as an exercise when the author was first learning Python.
- [Instructor] Python makes it relatively easy…to create your own reusable modules.…Here in Komodo I've opened a working copy of…saytime-test.py from chapter 14 of the exercise files.…This is an exercise that I tend to give myself…every time I learn a new language,…and, of course, I learned Python…a number of years ago, and so…this module has been around for a while.…But what this particular exercise is is to write a class…that will print the time in words.…
So, when I run this, you notice on the last line here,…there's a lot of unit tests before that.…It says, "local time is fourteen til four."…And so the exercise is for me to be able to…write a module that will give me the time…in words like that.…And if we look up here at the unit test data,…I've given it a number of times of day:…zero zero is midnight, one past midnight,…11 o'clock, noon, one o'clock,…29 past noon, half past noon,…29 'til one, quarter past noon.…
So there's all these different times in words…and this is the way that a person might…look at their analog clock and they'll say…
- Python anatomy
- Types and values
- Conditionals and operators
- Building loops
- Defining functions
- Python data structures: lists, tuples, sets, and more
- Creating classes
- Handling exceptions
- Working with strings
- File input/output (I/O)
- Creating modules
- Integrating a database with Python db-api
Skill Level Intermediate
Python: Programming Efficiently (2017)with Michele Vallisneri2h 15m Intermediate
2. Language Overview
3. Types and Values
8. Structured Data
11. String Objects
12. File I/O
13. Built-in Functions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.