Writing your First Python Program
Writing your First Python Program
February 28, 2012
CS0931 - Intro. to Comp. for the Humanities and Social Sciences
1
Textual Analysis
Define Problem
Find Data
Build a Concordance of a text ? Locations of words ? Frequency of words
Write a set of instructions
Python
? Word frequencies across time ? Determine authorship
? Count labels to determine liberal media bias
Solution
ACTACGTCGACTACGATCAC GATCGCGCGATCACGTATTT ACGATCAGCTACGATCGATC TACGATCGTAGCTGTGATCG
CS0931 - Intro. to Comp. for the Humanities and Social Sciences
2
The Big Picture
Overall Goal Build a Concordance of a text
? Locations of words ? Frequency of words
Today ? Briefly review expressions, assignments, & types ? Learn about defining functions ? Learn how to read in a text file and create a list of words ? Write a program to count the number of words in Moby Dick
CS0931 - Intro. to Comp. for the Humanities and Social Sciences
3
Last Class
1. Expressions
? Evaluate input and returns some output (calculator)
2. Assignments: =
? Store the value of the expression in the variable
instead of outputting the value.
? There is always an equals sign in an assignment
? Variables can be named many things
3. Types ? Integers vs. Floats (Decimals) ? Strings in single quotes ? Lists are sets of other types
General Rule: Expressions for a particular type will output that same type!
? We can index into Strings & Lists
? Indexed starting at 0!
CS0931 - Intro. to Comp. for the Humanities and Social Sciences
4
ACT2-1
? Do Task 1
1. Expressions
? Evaluate input and returns some output (calculator)
2. Assignments: =
? Store the value of the expression in the variable instead of
outputting the value.
? There is always an equals sign in an assignment
? Variables can be named many things
3. Types ? Integers vs. Floats (Decimals) ? Strings in single quotes ? Lists are sets of other types ? We can index into Strings & Lists
General Rule: Expressions for a particular type will output that same type!
? Indexed starting at 0!
CS0931 - Intro. to Comp. for the Humanities and Social Sciences
5
................
................
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
- data files in python
- writing your first python program
- reading and writing data files with python
- reading and writing vector data with ogr
- working with files in python
- c h a p r 2 file handling in python
- python programming 1 variables loops and
- basic python programming for loops and reading
- pyroot tutorial python
Related searches
- writing your first novel
- python program to convert decimal to binary
- python program to print the fibonacci sequence
- running a python program from command line
- writing your first book
- writing your first book checklist
- python program for fibonacci sequence
- python program example
- python program optional arguments
- writing your first blog post
- python program calculator
- run python program in cmd