Download presentation
Presentation is loading. Please wait.
Published byAdam Garrison Modified over 6 years ago
1
IST256 : Applications Programming for Information Systems
Modules
2
Agenda Connection Activity Teaching: Practice Activity
Quiz #5, Homework Check Teaching: Dictionaries Practice Activity Word Counts
3
Connect Activity Quiz # 5 Then Homework Check: Word Count Histogram
4
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.
5
Watch Me Code Import Modules: Import sys, math and random dir()
Short and sweet demo
6
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.
7
Watch Me Code Modules Import math Import math with alias
Import specific names from math Short and sweet demo
8
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 ?
9
Help me Code Print the current date and time. Like this:
Use the datetime module dir() and Python 3 docs to help you 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)
10
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”
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.