Skip to content

brendanpshea/computing_concepts_python

Repository files navigation

Computing Concepts With Python

Brendan Shea, PhD | [email protected]

Welcome to Computing Concepts With Python. This free, interactive textbook is designed to introduce the fundamental concepts of computer science through interactive learning. As a beginning student in this field, you are embarking on a journey to understand not only the theoretical underpinnings of computer systems and programming but also their practical applications. This textbook is unique as it is freely accessible, editable, and shareable under its OER license, supporting a collaborative and adaptive learning environment. I'd love to hear your feedback on what worked and what doesn't!

The chapters are deliveed in Jupyter notebooks, which means you'll be able to write and run code as you read. By default, you can do this with Google's (free) Colab computing platform. If you've never used Google Colab before, I think you'll find it's pretty intutive. I've put together a tutorial here: Ch 0: Brendan's Colab Tutorial.

The content of this textbook is organized into thematic chapters, each focused on a different aspect of computer science—from the basics of hardware and software to advanced topics in data structures, software engineering, and artificial intelligence. Each chapter is structured to facilitate both theoretical learning and practical application:

This introductory chapter provides a broad overview of the field of computer science and its fundamental concepts. It explains what computers are at their core - devices that execute algorithms to process information. The chapter traces the evolution of computers from early analog machines to modern digital devices. It introduces key components like the CPU, memory, and input/output systems, and explains how they work together using the fetch-decode-execute cycle and the von Neumann architecture. The chapter also covers number systems used in computing, such as binary, and provides a glimpse into the development of operating systems over time. Throughout, it emphasizes how computer science combines theoretical ideas with practical engineering to create the powerful information processing systems that shape our world.

In this chapter, we dive into the world of computer files and formats, exploring how computers store and interpret various types of data. We start with the fundamentals of plain text files, character encoding standards like ASCII and Unicode, and the role of markup languages in structuring and presenting information. Next, we examine source code files for different programming languages and the distinction between interpreted and compiled languages. We then explore how computers represent and store different types of media, including images, audio, and productivity files. Throughout the chapter, we emphasize the importance of understanding file formats, compression techniques, and the trade-offs involved in working with digital data. The chapter concludes with an introduction to file organization and management in the Ubuntu operating system, setting the stage for hands-on interaction with files and directories.

This chapter introduces the fundamental concepts of computer networking, explaining how devices are interconnected to allow communication and data sharing. It begins by distinguishing between Local Area Networks (LANs) and Wide Area Networks (WANs), and then dives into the four-layer TCP/IP network model. The chapter explains the roles of each layer - Application, Transport, Internet, and Network Interface - using relatable analogies. It covers key protocols like HTTP, TCP, UDP, and IP, and introduces essential networking devices such as routers, switches, and modems. The chapter also provides a brief history of the internet and its evolution. Hands-on sections introduce HTML and CSS, equipping learners with the skills to create basic web pages. Throughout, the chapter emphasizes how an understanding of networks is crucial in our increasingly interconnected digital world.

This chapter provides an engaging introduction to the Python programming language, starting with the fundamentals of what programming is and how it differs from natural languages. It guides learners through setting up and using Google Colab as a platform for writing and running Python code. The chapter then dives into core programming concepts, including variables, user input, comments, and pseudocode. It explores the rich capabilities of Python for working with strings, covering topics such as concatenation, repetition, slicing, case manipulation, character replacement, and formatted strings using f-strings. Throughout, the material is brought to life with relatable examples, like analyzing Monty Python quotes. The chapter emphasizes the importance of reading documentation and provides a handy reference for common string operations. Engaging exercises challenge learners to put their new skills into practice, reinforcing the key concepts.

This chapter dives into the fundamental building blocks of Python programming: data types and functions. It introduces the concept of data types, explaining Python's dynamic typing system and exploring common types like integers, floats, strings, and lists. The chapter provides hands-on examples of working with these data types, including arithmetic operations, user input, and list manipulation. It also covers the importance of data types and potential errors that can arise from type mismatches. The second half of the chapter focuses on defining and using functions in Python. It explains how to create functions with parameters, return values, and demonstrates their utility through practical examples. The chapter concludes with a deep dive into the concept of a byte and its various interpretations in computing, from character encoding to machine code instructions.

This chapter explores two key concepts in Python programming: conditionals and levels of abstraction. It begins by introducing conditionals, which allow programs to make decisions based on whether certain conditions are true or false. The chapter covers the if, elif, and else keywords, boolean operators like and, or, and not, and the concise ternary conditional expression. It provides hands-on examples of using conditionals, such as a simple movie recommendation app and exercises involving decision-making in a fictional Star Wars universe. The second part of the chapter dives into the concept of abstraction, examining how different levels of abstraction are used in programming languages, software development approaches, data representation, and real-world systems. It compares the varying levels of abstraction in C, Java, and Python, illustrating how higher levels of abstraction can make programming more user-friendly and efficient, albeit with potential performance tradeoffs. The chapter concludes with a step-by-step explanation of how computers execute Python code, from parsing and tokenization to bytecode compilation and execution.

This chapter dives into the world of algorithms and loops, using engaging examples from the Legend of Zelda video game series. It begins by defining algorithms and their essential characteristics: precision, finiteness, input, output, and effectiveness. The chapter then explores the importance of algorithms in computer science, discussing their role in efficient problem-solving, intelligent decision-making, and scalability. It examines how computer scientists study algorithms through theoretical analysis, empirical evaluation, and algorithmic design and innovation. The second part of the chapter focuses on loops in Python, covering for loops, the range() function, nested loops, the continue and break statements, and iterating through strings. It also introduces while loops, discussing their syntax, complex conditions, infinite loops, user input validation, and the else clause. Throughout, the chapter reinforces concepts with hands-on exercises and thought-provoking discussion questions. The case study on the search-sort tradeoff, featuring Princess Peach and Toadette, provides a relatable context for understanding the efficiency of algorithms and the concept of Big O notation.

This chapter takes readers on a captivating journey through the history of information security, from the early days of the Caesar cipher to the cutting-edge techniques of artificial intelligence. It introduces the CIA triad (Confidentiality, Integrity, Availability) as a guiding framework for understanding the evolution of security practices. The chapter explores the emergence of computer networks, highlighting the pioneering work of Paul Baran and Donald Davies on packet switching and the development of the ARPANET. It discusses the four-layer network model and the various threats that target each layer, providing historical examples of unauthorized access, malware, denial of service attacks, data interception, and social engineering. The chapter then delves into the role of cryptography in securing communication, explaining symmetric and asymmetric encryption, hashing, and digital signatures. It showcases the Modulo Hash algorithm and provides an engaging exercise on implementing a simple hash function. The chapter concludes by examining the different types of threat actors interested in personal data and offering practical methods for protecting information, emphasizing the importance of a multi-layered, defense-in-depth approach to security in the digital age.

This chapter deals with the vast and crucial world of data and databases. It explains the concept of data, its various types, and its critical role in computer science and decision-making across different fields. The chapter introduces databases as tools for efficiently storing, managing, and retrieving data, underlining their significance in handling the ever-growing volume of digital information.

This chapter transitions students into more advanced topics, starting with Python dictionaries, a versatile data structure. It then explores object-oriented programming by introducing objects, a crucial concept in modern software development. The chapter also covers the art of testing code, emphasizing the importance of this practice for ensuring code reliability and functionality. Additionally, it touches upon fundamental software engineering methodologies, providing a comprehensive overview of these key areas in computer science.

This chapter provides a comprehensive overview of the early history of artificial intelligence, tracing the evolution of key ideas, figures, and developments that laid the foundation for the field. It begins by exploring the origins of formal logic in ancient philosophy, highlighting Aristotle's influential work on syllogisms and valid reasoning. The chapter then delves into the contributions of Islamic Golden Age scholars like al-Khwarizmi, who introduced the concept of algorithms as a systematic approach to problem-solving. It examines the groundbreaking work of René Descartes in bridging geometry and algebra through analytic geometry and raising philosophical questions about the existence of other minds. The chapter also covers the development of calculus by Newton and Leibniz, the emergence of probability theory through the work of Pascal, Bayes, and Laplace, and the formalization of modern logic by Boole, Frege, and Gödel. It introduces key concepts in computing and AI, such as Lovelace's Objection, Turing machines, the halting problem, and the Turing Test. The chapter concludes by discussing the rise of symbolic AI and statistical machine learning, showcasing their applications through engaging case studies and hands-on exercises.

Chapter 12, "Neural Nets, offers a history of neurel nets and their applications (with a Moby Dick Theme). It starts by demonstrating how to bulit a simple "perceptron" (an artificial neuron), and then shows how these can be combined into more complex neural networks. The chapter covers convolutional neural networks (CNNs), recurrent neural networks (RNNs), and the "tranformers" that power technologies like chatGPT. The chapter closes with an overview of some major issues in AI Ethics.

A Note on the Use of AI Tools. These chapters were intitially developed as the “generative AI” explosion took off (staring with OpenAI’s GPT 3.0), and I’ve had fun experimenting with many of these tools—including successive versions of ChatGPT, Google Bard, Claude, Codey, CoPilot, Mistral, and others—in helping to turn my (voluminous, but often unorganized) lecture notes into something resembling a proper book. My experience was these tools with these has been generally positive, and I think that they can someday do at least some of the work done by traditional editors and publishing houses (I say this as a former editor at an academic press!). I’m less convinced they are going to immediately replace the actual writer or programmer, though, as there’s still a fair amount of expertise (and effort!) into producing quality, meaningful output.