{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Workbook for Chapter 6 of Explorations in Computing"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Section 6.3: Counting Words in a Text File"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Execute this cell to initialize the notebook:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from PythonLabs.Tools import path_to_data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Exercises"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"T31. Type an assignment statement that verifies multiple target assignments work as described in this section:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"T32. Confirm the fact you have two new variables by using them in some expressions:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### `wc` "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Enter the definition of the word count function (`wc`) in the code cell below.\n",
"* If you want to copy and paste the code you'll find it at `wc.py`\n",
"* If you are going to enter your own version, you have a good \"template\" in the `filesize` function you wrote for the last section; consider copying that definition and using it as a starting point."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"T38. Run the code cell that contains your `wc` function, then test it on `quote1.txt`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"T39. Repeat the call, but this time save the results in three variables:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"T40. Verify the fact that Python assigned values to all three variables by asking for their values:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}