Introduction to: Computers & Programming: Input and Output ...
[Pages:34]Introduction to: Computers & Programming: Input and Output (IO)
Adam Meyers New York University
Intro to: Computers & Programming: Loops in Python V22.0002-001
Summary
? What is Input and Ouput? ? What kinds of Input and Output have we covered so far?
? print (to the console) ? input (from the keyboard)
? File handling
? input from files ? output to files ? Text files vs. 'pickled' binary files ? URL handling
Intro to: Computers & Programming: Loops in Python V22.0002-001
Input
? Input is any information provided to the program
? Keyboard input ? Mouse input ? File input ? Sensor input (microphone, camera, photo cell, etc.)
? Output is any information (or effect) that a program produces:
? sounds, lights, pictures, text, motion, etc. ? on a screen, in a file, on a disk or tape, etc.
Intro to: Computers & Programming: Loops in Python V22.0002-001
Types of Input Covered in This Class
? So Far
? Input: keyboard input only ? Output: graphical and text output transmitted to the
computer screen
? This Unit expands our repertoire to include:
? File Input ? Python can read in the contents of files ? File Output ? Python can write text to files
Intro to: Computers & Programming: Loops in Python V22.0002-001
Files
? File = Named Data Collection stored on memory device ? Different types of data: text, binary, etc ? Accessible by name or address ? Has start and end point ? Program can read, created, modified, (and do other things to) files
? Text file can be treated like a (big) string ? Human readable ? ASCII/UTF-8/etc. encoding ? Can be plain text or can contain markup (e.g., html)
? Binary files: not human readable, usually require specific programs to read
Intro to: Computers & Programming: Loops in Python V22.0002-001
Folders/Directories and Paths
? A Folder or a Directory is a named stored item that contains other folders and/or Files
? The root directory of a storage device:
? no other directory contains it ? it contains all other directories/files on that storage device.
? A sequence from directory to directory to directory ... ending in a directory or file is called a path.
? Each item n in the path (except the root) is contained by the n-1 item.
? There is at least one path from the root to every file & directory, i.e., paths can be used to identify/locate files
? Each path uniquely identifies a single directory or file (ignoring short cuts, aka, symbolic links)
Intro to: Computers & Programming: Loops in Python V22.0002-001
Slash Notation for Representing Paths
? Unix operating systems (linux, Apple, Android, etc.) use the forward slash to connect directories in a path, e.g., the path for this file could be:
/Users/Adam/Desktop/Class Talks/Input-Output.odp
? MSDOS, Windows and related systems use the backslash instead \
? The root directory in UNIX systems is labeled / ? In Windows it is a letter and a colon, e.g., C:
Intro to: Computers & Programming: Loops in Python V22.0002-001
The Directory Tree Including this File
Intro to: Computers & Programming: Loops in Python V22.0002-001
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- oop in python
- python 3 tutorialspoint
- basic python programming for loops and reading files
- file handling
- python data file hanling
- reading and writing data files with python
- data files in python
- reading and writing vector data with ogr
- exercise 5 building arcgis tools using python
- introduction to computers programming input and output