Facebook Pixel
Searching...
English
EnglishEnglish
EspañolSpanish
简体中文Chinese
FrançaisFrench
DeutschGerman
日本語Japanese
PortuguêsPortuguese
ItalianoItalian
한국어Korean
РусскийRussian
NederlandsDutch
العربيةArabic
PolskiPolish
हिन्दीHindi
Tiếng ViệtVietnamese
SvenskaSwedish
ΕλληνικάGreek
TürkçeTurkish
ไทยThai
ČeštinaCzech
RomânăRomanian
MagyarHungarian
УкраїнськаUkrainian
Bahasa IndonesiaIndonesian
DanskDanish
SuomiFinnish
БългарскиBulgarian
עבריתHebrew
NorskNorwegian
HrvatskiCroatian
CatalàCatalan
SlovenčinaSlovak
LietuviųLithuanian
SlovenščinaSlovenian
СрпскиSerbian
EestiEstonian
LatviešuLatvian
فارسیPersian
മലയാളംMalayalam
தமிழ்Tamil
اردوUrdu
Python for Informatics

Python for Informatics

Exploring Information: Exploring Information
by Charles Severance 2002 246 pages
3.99
500+ ratings
Listen
Listen to Summary

Key Takeaways

1. Programming: A Creative and Rewarding Skill

Writing programs (or programming) is a very creative and rewarding activity.

Creative problem-solving. Programming is not just about writing code; it's about solving problems in a creative and logical way. It allows you to build tools and solutions that can automate tasks, analyze data, and even create art. The process of programming involves breaking down complex problems into smaller, manageable steps, and then expressing those steps in a language that a computer can understand.

Empowerment and control. Learning to program empowers you to take control of technology and make it work for you. Instead of being a passive user of software, you become a creator, able to shape technology to meet your specific needs. This can be incredibly rewarding, both personally and professionally.

  • Automate repetitive tasks
  • Analyze data to gain insights
  • Build custom tools and applications

Lifelong learning. The field of programming is constantly evolving, so learning to program is a journey of continuous growth and discovery. As you learn new languages and techniques, you will develop a deeper understanding of how computers work and how to use them to solve problems.

2. Computers: Fast, Capable, and Literal

Our computers are fast and have vast amounts of memory and could be very helpful to us if we only knew the language to speak to explain to the computer what we would like it to “do next”.

Speed and memory. Computers are incredibly fast and have vast amounts of memory, making them ideal for handling repetitive and complex tasks. They can perform calculations and process data at speeds that are impossible for humans. This makes them powerful tools for automation and analysis.

  • CPUs operate at billions of cycles per second
  • Main memory provides fast access to data
  • Secondary memory stores data persistently

Literal interpretation. Computers are extremely literal and follow instructions exactly as they are written. They do not make assumptions or interpret instructions based on context. This means that programmers must be precise and unambiguous in their code.

  • Syntax errors stop program execution
  • Logic errors produce incorrect results
  • Semantic errors cause unintended behavior

Partnership with humans. Computers are good at tasks that humans find boring and tedious, while humans excel at creativity, intuition, and problem-solving. By learning to program, you can leverage the strengths of both humans and computers to achieve more than either could alone.

3. Python: A Language for Humans and Computers

The nice thing about telling Python to speak is that we can even tell it what to say by giving it a message in quotes.

Human-readable syntax. Python is designed to be relatively easy for humans to read and write, making it a great language for beginners. Its syntax is clear and concise, and it uses English-like keywords, making it easier to understand the logic of a program.

  • Small vocabulary of reserved words
  • Clear and consistent syntax
  • Emphasis on readability

Interpreted language. Python is an interpreted language, which means that it executes code line by line, making it easy to test and debug programs. This interactive nature of Python makes it a great language for experimentation and learning.

  • Interactive mode for testing code
  • Immediate feedback on errors
  • Ability to execute code one line at a time

Versatile and powerful. Python is a versatile language that can be used for a wide range of tasks, from simple scripting to complex data analysis and web development. It has a large and active community, which means that there are many libraries and resources available to help you learn and build programs.

4. Variables, Expressions, and Statements: The Building Blocks

A variable is a name that refers to a value.

Variables as containers. Variables are names that refer to values, allowing you to store and manipulate data in your programs. They are like containers that hold information, and you can use their names to access and modify the data they contain.

  • Assignment statements create variables
  • Variable names should be meaningful
  • Variables have a type based on their value

Expressions as computations. Expressions are combinations of values, variables, and operators that represent a single result. They are the way you perform calculations and manipulate data in your programs.

  • Operators perform computations
  • Operands are the values operators act on
  • Order of operations determines evaluation

Statements as actions. Statements are units of code that the Python interpreter can execute. They are the instructions that tell the computer what to do.

  • Assignment statements store values
  • Print statements display output
  • Statements are executed sequentially

5. Conditional Execution: Making Decisions

The boolean expression after the if statement is called the condition.

Boolean expressions. Boolean expressions are expressions that evaluate to either true or false. They are used to make decisions in your programs, allowing you to execute different code based on different conditions.

  • Comparison operators (==, !=, >, <, >=, <=)
  • Logical operators (and, or, not)
  • Boolean values (True, False)

If statements. If statements allow you to execute a block of code only if a certain condition is true. They are the basic building blocks for making decisions in your programs.

  • If statement with a condition
  • Indented block of code
  • Optional else clause for alternative execution

Chained and nested conditionals. You can combine multiple if statements using elif (else if) to create more complex decision-making structures. You can also nest if statements inside other if statements to create even more intricate logic.

  • elif for multiple conditions
  • Nested if statements for complex logic
  • Avoid excessive nesting for readability

6. Functions: Reusable Code Blocks

A function is a named sequence of statements that performs a computation.

Organizing code. Functions allow you to group a sequence of statements into a reusable block of code. This makes your programs more organized, easier to read, and easier to maintain.

  • Function definitions specify name and statements
  • Function calls execute the statements
  • Functions can take arguments and return values

Built-in functions. Python provides a number of built-in functions that you can use without having to define them yourself. These functions perform common tasks, such as finding the maximum or minimum value in a list, or converting a value from one type to another.

  • max(), min(), len()
  • int(), float(), str()
  • random.random(), math.sin()

User-defined functions. You can also define your own functions to perform specific tasks in your programs. This allows you to create reusable code blocks that can be called from different parts of your program.

  • def keyword for function definition
  • Parameters for input values
  • return statement for output values

7. Iteration: Repeating Tasks

This type of flow is called a loop because the third step loops back around to the top.

While loops. While loops allow you to repeat a block of code as long as a certain condition is true. They are useful for tasks that need to be repeated an unknown number of times.

  • Condition is evaluated before each iteration
  • Body of the loop is executed if condition is true
  • Loop continues until condition is false

For loops. For loops allow you to repeat a block of code for each item in a sequence. They are useful for tasks that need to be performed on a list of items.

  • Iteration variable steps through the sequence
  • Body of the loop is executed for each item
  • Loop continues until all items are processed

Loop patterns. Loops are often used to perform common tasks, such as counting, summing, finding the maximum or minimum value in a list. These patterns can be used in both while and for loops.

  • Counting loops
  • Summing loops
  • Maximum and minimum loops

8. Strings: Sequences of Characters

A string is a sequence of characters.

Accessing characters. Strings are sequences of characters, and you can access individual characters using the bracket operator. The index of the first character is 0.

  • Bracket operator for indexing
  • Negative indices count from the end
  • Index must be an integer

String operations. Strings support a number of operations, such as concatenation, slicing, and comparison. These operations allow you to manipulate and compare strings in your programs.

  • Concatenation with +
  • Slicing with [n:m]
  • Comparison with ==, <, >

String methods. Strings are objects, and they have a number of built-in methods that you can use to perform common tasks, such as finding a substring, converting to uppercase or lowercase, and removing whitespace.

  • len(), find(), upper(), lower()
  • strip(), startswith(), count()
  • Method calls use dot notation

9. Files: Storing and Retrieving Data

Secondary memory is not erased even when the power is turned off.

Persistence. Files allow you to store data on secondary memory, which persists even when the power is turned off. This allows you to save data between program runs and share data with other programs.

  • Secondary memory for persistent storage
  • Files are stored on disk or other media
  • Files can be read and written

Opening files. Before you can read or write a file, you must first open it using the open() function. This function returns a file handle, which you can use to access the file's contents.

  • open() function for opening files
  • File handles for accessing data
  • Different modes for reading and writing

Reading and writing files. You can read the contents of a file using the read() method or by looping through the lines of the file. You can write data to a file using the write() method.

  • read() method for reading entire file
  • For loop for reading line by line
  • write() method for writing data

10. Lists: Ordered Collections

A list is a sequence of values.

Ordered sequences. Lists are ordered sequences of values, which can be of any type. They are similar to strings, but they are mutable, meaning that you can change their contents.

  • Elements can be any type
  • Elements are indexed by integers
  • Lists are mutable

List operations. Lists support a number of operations, such as concatenation, slicing, and repetition. These operations allow you to manipulate and combine lists in your programs.

  • Concatenation with +
  • Slicing with [n:m]
  • Repetition with *

List methods. Lists are objects, and they have a number of built-in methods that you can use to perform common tasks, such as adding elements, removing elements, and sorting the list.

  • append(), extend(), sort()
  • pop(), remove(), del
  • List methods modify the list

11. Dictionaries: Key-Value Pairs

A dictionary is like a list, but more general.

Mappings. Dictionaries are mappings from keys to values. They are similar to lists, but they are not ordered, and you can use any immutable type as a key.

  • Keys must be immutable
  • Values can be any type
  • Dictionaries are not ordered

Dictionary operations. Dictionaries support a number of operations, such as adding, removing, and updating key-value pairs. You can also use the in operator to check if a key exists in the dictionary.

  • Bracket operator for accessing values
  • in operator for checking keys
  • get() method for default values

Looping through dictionaries. You can loop through the keys of a dictionary using a for loop. You can also loop through the key-value pairs using the items() method.

  • For loop iterates through keys
  • items() method for key-value pairs
  • Keys are in no particular order

12. Tuples: Immutable Sequences

The important difference is that tuples are immutable.

Immutable sequences. Tuples are sequences of values, similar to lists, but they are immutable, meaning that you cannot change their contents after they are created.

  • Elements can be any type
  • Elements are indexed by integers
  • Tuples are immutable

Tuple operations. Tuples support many of the same operations as lists, such as indexing, slicing, and concatenation. However, they do not support operations that modify the tuple.

  • Indexing with bracket operator
  • Slicing with [n:m]
  • Concatenation with +

Tuple assignment. Python allows you to assign multiple variables at once using tuple assignment. This is a convenient way to unpack the elements of a sequence into separate variables.

  • Multiple assignment in one statement
  • Swapping values with tuple assignment
  • Unpacking sequences into variables

13. Regular Expressions: Pattern Matching

The power of the regular expressions comes when we add special characters to the search string that allow us to more precisely control which lines match the string.

Search strings with special characters. Regular expressions are a powerful way to search for patterns in strings. They use special characters to represent different types of characters and patterns.

  • Special characters for matching patterns
  • Wildcards for matching any character
  • Character sets for matching specific characters

Extracting data. Regular expressions can be used to extract data from strings using the findall() method. This method returns a list of all the substrings that match a given pattern.

  • findall() method for extracting substrings
  • Parentheses for capturing groups
  • Non-greedy matching with ?

Combining searching and extracting. You can combine searching and extracting using regular expressions to find lines that match a certain pattern and then extract specific data from those lines.

  • Search for lines with a pattern
  • Extract data from matching lines
  • Use parentheses to capture specific data

14. Networked Programs: Connecting to the World

A socket is much like a file, except that a single socket provides a two-way connection between two programs.

Sockets for network connections. Sockets are a low-level way to make network connections between two programs. They allow you to send and receive data over the network.

  • Sockets for two-way communication
  • Sending and receiving data
  • Need for protocols to coordinate communication

HTTP protocol. The HyperText Transfer Protocol (HTTP) is the protocol that powers the web. It defines how web browsers and web servers communicate with each other.

  • GET request for retrieving data
  • Headers for describing the document
  • Body for the document content

Retrieving web pages. You can use the socket library to manually send and receive data over HTTP, or you can use the urllib library to simplify the process of retrieving web pages.

  • urllib.urlopen() for opening web pages
  • Treating web pages like files
  • Reading data from web pages

15. Web Services: Exchanging Data

When we use an API, generally one program makes a set of services available for use by other applications and publishes the APIs (i.e., the “rules”) that must be followed to access the services provided by the program.

XML for structured data. XML is a markup language that is used to represent structured data. It is often used for exchanging data between applications.

  • Tags for marking up data
  • Attributes for adding metadata
  • ElementTree library for parsing XML

JSON for data exchange. JSON is a lightweight data format that is based on JavaScript object syntax. It is often used for exchanging data between web applications.

  • Key-value pairs for representing data
  • Lists for representing sequences
  • json library for parsing JSON

APIs for application interaction. Application Programming Interfaces (APIs) are contracts between applications that define how they can interact with each other. They allow you to build programs that make use of services provided by other programs.

  • Web services for APIs over the web
  • API keys for authentication
  • OAuth for secure access

16. Databases and SQL: Organizing Data

A database is a file that is organized for storing data.

Persistent storage. Databases are files that are organized for storing data. They are stored on disk, so they persist after the program ends.

  • Databases for persistent storage
  • Tables, rows, and columns
  • Indexes for fast data access

Structured Query Language (SQL). SQL is a language for interacting with databases. It allows you to create tables, insert data, retrieve data, update data, and delete data.

  • CREATE TABLE for creating tables
  • INSERT for adding data
  • SELECT for retrieving data
  • UPDATE for modifying data
  • DELETE for removing data

Data modeling. Data modeling is the process of deciding how to organize your data into tables and relationships. It is an important part of database design.

  • Primary keys for unique identification
  • Foreign keys for linking tables
  • Normalization for avoiding data duplication

17. Visualizing Data: Making Sense of Information

In this chapter, we take a look at three complete applications that bring all of these things together to manage and visualize data.

Geocoding data on a map. You can use the Google geocoding API to convert addresses into latitude and longitude coordinates, and then display those coordinates on a Google map.

  • Geocoding API for converting addresses
  • Google Maps API for displaying data
  • JavaScript for creating interactive maps

Visualizing networks. You can use the D3 JavaScript library to visualize networks and interconnections between data points. This can be useful for understanding relationships between people, web pages, or other entities.

  • D3 library for network visualization
  • Force-directed layouts for node placement
  • JSON for data exchange

Visualizing email data. You can use Python to analyze email data and create visualizations of email activity, such as word clouds and time series charts.

  • Analyzing email data
  • Creating word clouds
  • Visualizing data over time

18. Automating Tasks: Making Life Easier

Simple Python scripts can make short work of simple tasks that must be done to hundreds or thousands of files spread across a directory tree or your entire computer.

File system navigation. The os module provides functions for working with files and directories. You can use these functions to navigate through your computer's file system.

  • os.getcwd() for current directory
  • os.path.abspath() for absolute paths
  • os.path.exists() for checking existence
  • os.path.isdir() and os.path.isfile() for checking type
  • os.listdir() for listing files

Walking directory trees. The os.walk() function allows you to traverse through all the directories and subdirectories in a tree. This is useful for performing operations on all the files in a directory tree.

  • os.walk() for traversing directories
  • For loop for processing files
  • Recursive traversal of subdirectories

Automating file operations. You can use Python to automate common file operations, such as renaming files, deleting files, and moving files. This can save you a lot of time and effort when you need to perform these operations on a large number of files.

  • os.path.join() for creating file paths
  • os.path.getsize() for file size
  • os.remove() for deleting files

Last updated:

Review Summary

3.99 out of 5
Average of 500+ ratings from Goodreads and Amazon.

Python for Informatics receives mixed reviews, with an average rating of 3.99/5. Readers appreciate its accessibility for beginners and free availability. Many find it a good introduction to Python basics, especially when paired with the author's Coursera course. However, some criticize the rapid progression of difficulty and lack of exercises in later chapters. The book's focus on Python 2.7 is noted as a drawback for those learning Python 3. Overall, it's considered a valuable resource for those new to programming, particularly in data analysis applications.

Your rating:

About the Author

Charles Severance is a Clinical Associate Professor at the University of Michigan's School of Information. He is involved in promoting educational technology standards and open educational resources. Severance teaches popular MOOCs on Coursera, including Programming for Everybody. He has authored several books on technology and programming, including "Python for Informatics" and "Using Google App Engine." With a Ph.D. in Computer Science from Michigan State University, Severance has a background in computing standards and media. He has hosted technology-focused TV and radio shows, and pursues hobbies such as off-road motorcycle riding and hockey.

Download EPUB

To read this Python for Informatics summary on your e-reader device or app, download the free EPUB. The .epub digital book format is ideal for reading ebooks on phones, tablets, and e-readers.
Download EPUB
File size: 2.95 MB     Pages: 6
0:00
-0:00
1x
Dan
Andrew
Michelle
Lauren
Select Speed
1.0×
+
200 words per minute
Create a free account to unlock:
Requests: Request new book summaries
Bookmarks: Save your favorite books
History: Revisit books later
Recommendations: Get personalized suggestions
Ratings: Rate books & see your ratings
Try Full Access for 7 Days
Listen, bookmark, and more
Compare Features Free Pro
📖 Read Summaries
All summaries are free to read in 40 languages
🎧 Listen to Summaries
Listen to unlimited summaries in 40 languages
❤️ Unlimited Bookmarks
Free users are limited to 10
📜 Unlimited History
Free users are limited to 10
Risk-Free Timeline
Today: Get Instant Access
Listen to full summaries of 73,530 books. That's 12,000+ hours of audio!
Day 4: Trial Reminder
We'll send you a notification that your trial is ending soon.
Day 7: Your subscription begins
You'll be charged on Mar 22,
cancel anytime before.
Consume 2.8x More Books
2.8x more books Listening Reading
Our users love us
100,000+ readers
"...I can 10x the number of books I can read..."
"...exceptionally accurate, engaging, and beautifully presented..."
"...better than any amazon review when I'm making a book-buying decision..."
Save 62%
Yearly
$119.88 $44.99/year
$3.75/mo
Monthly
$9.99/mo
Try Free & Unlock
7 days free, then $44.99/year. Cancel anytime.
Settings
Appearance
Black Friday Sale 🎉
$20 off Lifetime Access
$79.99 $59.99
Upgrade Now →