An Introduction to
Computer Science
with Java, Python and C++
Community College of Philadelphia edition
Copyright 2018 by C.W. Herbert, all rights reserved.
Last edited September 24, 2018 by C. W. Herbert
This document is a draft of a chapter from An Introduction to Computer Science with Java, Python and C++, written by Charles
Herbert. It is available free of charge for students in Computer Science courses at Community College of Philadelphia during the
Fall 2018 semester. It may not be reproduced or distributed for any other purposes without proper prior permission.
Please report any typos, other errors, or suggestions for improving the text to [email protected]
Contents
Chapter 3 – Programming Logic .................................................................................................................... 3
Boolean Logic in Branching and Looping .......................................................................... 4
Boolean Relational Operations ............................................................................................................. 5
Boolean Relational Operators in Python .............................................................................................. 5
Boolean Logical Operations .................................................................................................................. 7
Boolean Logical Operators in Python .................................................................................................. 10
Boolean Expressions Using Boolean Variables .................................................................................... 10
CheckPoint 3.1 ..................................................................................................................................... 11
The Nature of Algorithms................................................................................................ 12
Turing Machines and the Church-Turing Thesis ................................................................................. 12
Elements of Logical Structure in Algorithms ....................................................................................... 16
Tools for Describing Algorithms .......................................................................................................... 19
Linear Sequences ................................................................................................................................ 23
CheckPoint 3.2 ..................................................................................................................................... 24
Conditional Execution (Branching ) ................................................................................. 24
Binary Branching – Bypass vs. Choice ................................................................................................. 24
Binary Branching in Python ................................... ...