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
Build a Concordance of
a text
? Locations of words
? Frequency of words
? Word frequencies across time
? Determine authorship
? Count labels to determine
liberal media bias
Find Data
Write a set of
instructions
Python
Solution
CS0931 - Intro. to Comp. for the Humanities and Social Sciences
ACTACGTCGACTACGATCAC
GATCGCGCGATCACGTATTT
ACGATCAGCTACGATCGATC
TACGATCGTAGCTGTGATCG
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
General Rule: Expressions
? Integers vs. Floats (Decimals)
for a particular type will
? Strings in single quotes
output that same type!
? Lists are sets of other types
? 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.
2.
3.
Expressions
? Evaluate input and returns some output (calculator)
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
Types
General Rule:
? Integers vs. Floats (Decimals)
Expressions for a
? Strings in single quotes
particular type will
? Lists are sets of other types
output that same type!
? We can index into Strings & Lists
? 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
- python programming an introduction to
- python simple programs creating and executing
- reading and writing data files with python
- writing your first python program
- esci 386 scientific programming analysis and
- c h a p r 2 file handling in python
- python input output and variables
- ce 549 python lab 1 introduction to 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