IST256 : Applications Programming for Information Systems Modules
Agenda Connection Activity Teaching: Practice Activity Quiz #5, Homework Check Teaching: Dictionaries Practice Activity Word Counts
Connect Activity Quiz # 5 Then Homework Check: Word Count Histogram
Modules Python modules are separate files of Python code. When you import a module, Python executes the and all the variables and functions (i.e. names) in the module become available to your program. The dir() function will display the names defined by the module.
Watch Me Code Import Modules: Import sys, math and random dir() Short and sweet demo
Avoiding Name Errors Since real programs import several modules, to avoid name errors we can elect to import specific items from the module. This improves performance buy avoiding the execution of unnecessary code. We can also choose to alias a module and give it another name.
Watch Me Code Modules Import math Import math with alias Import specific names from math Short and sweet demo
90 Second Challenge from a import b,c import d as e What is a ? What is b ? What is c ? What is d ? What is e ?
Help me Code Print the current date and time. Like this: Use the datetime module dir() and Python 3 docs to help you https://github.com/mafudge/datasets/blob/master/customers/customers.csv Similar to this: file = '/pub/datasets/grades/fall2015.tsv' grades = list() with open(file) as inp: for line in inp: values = line.split() vald = { 'course': values[2], 'credits': values[3], 'grade' : values[4] } grades.append(vald)
Now You Code Print Names of Notebook Files Write a program to print out the .ipynb notebook files in your current folder. Suggested Approach Import the os module. Figure out which function to use. Figure out what the data type of the output of the function is. Filter the directory output to just display those files which end in “.ipynb”