Skip to main content
main-content

Über dieses Buch

Computer programming is a skill that can bring great enjoyment from the creativity involved in designing and implementing a solution to a problem. This classroom-tested and easy-to-follow textbook teaches the reader how to program using Python, an accessible language which can be learned incrementally. Through an extensive use of examples and practical exercises, students will learn to recognize and apply abstract patterns in programming, as well as how to inspect the state of a program using a debugger tool. Features: contains numerous examples and solved practice exercises designed for an interactive classroom environment; highlights several patterns which commonly appear in programs, and presents exercises that reinforce recognition and application of these patterns; introduces the use of a debugger, and includes supporting material that reveals how programs work; presents the Tkinter framework for building graphical user interface applications and event-driven programs; provides helpful additional resources for instructors at the associated website: http://cs.luther.edu/~leekent/CS1. This hands-on textbook for active learning in the classroom will enable undergraduates in computer science to develop the necessary skills to begin developing their own programs. It employs Python as the introductory language due to the wealth of support available for programmers.

Inhaltsverzeichnis

Frontmatter

1. Introduction

Chapter one introduces the reader to computer programming using Python by first demonstrating how to install the Python interpreter on a computer. An Integrated Development Environment (IDE) is an environment for writing computer programs and chapter one also recommends an IDE and demonstrates how to install it and begin using it.
The first chapter continues by illustrating how to write a first program using Python to test that the IDE was correctly installed. The chapter goes on to introduce the reader to some introductory computer architecture providing an appreciation for what programming languages do for us while giving readers a deeper understanding of how Python works. Chapter one concludes by introducing by introducing assignment statements, the importance of types in Python, and how to get input and print formatted output using Python. Types of data introduced include integers, real numbers, and strings.
Kent D. Lee

2. Decision Making

The second chapter introduces the reader to making decisions in Python programs. The word “selection” refers to selecting between alternatives and the “if” statement in Python is how programmers perform selection in their programs.
Using if statements is a very important aspect of programming but can lead to very complicated and unwieldy programs. Chapter two shows the reader how to properly use if statements in their programs by demonstrating techniques for some common patterns. In particular, the guess and check pattern is introduced to students by examples and practice problems. Boolean (i.e. true and false) values and exception handling are also introduced in this chapter since they both are related to performing selection within a program.
Kent D. Lee

3. Repetitive Tasks

This chapter introduces the reader to iteration including the “for” loop and the “while” loop. Computers are very good at doing repetitive tasks, often called iteration in Computer Science lingo. Chapter three shows the reader how to iterate over sequences in Python like strings, lists, and files. In addition, the guess and check pattern is presented again in this chapter in a format that can be used to guess and check assumptions about all elements of a sequence.
Mutability of data and the accumulator pattern are important ideas that are described in this chapter along with examples and practice problems that help the reader understand and apply these concepts.
Kent D. Lee

4. Using Objects

Chapter four introduces concepts from Object-Oriented Programming (OOP). The chapter describes what an object is and how objects are used in Python programming. Objects are so integral to Python that readers are actually introduced to OOP starting in the first chapter, but chapter four is more intentional about understanding the OOP paradigm.
The chapter introduces OOP to the reader by introducing turtle graphics programming. Learning turtle graphics is both fun and challenging with instant feedback available from the graphics that the reader programs. OOP is further emphasized by learning to read XML files. XML files are formatted data files with a structure that can be parsed using an XML parser. Readers learn what a parser is and how to use it to parse XML files.
Finally, XML processing and turtle graphics are combined to plot exercise data captured from an exercise computer, tying the use of OOP in XML processing and graphics programming together. In addition, dictionary objects in Python are also introduced as the last built-in data type covered in the text.
Kent D. Lee

5. Defining Functions

The fifth chapter introduces the reader to defining functions. Since the first chapter, functions have been used. In chapter five the reader is introduced to writing their own functions. Other topics related to defining functions are covered including parameter passing and return values, scope of variables, and the run-time stack. Top-down and bottom-up design are illustrated as well in relationship to defining functions.
The varied parameter passing mechanisms of Python are explored including keyword arguments, default values, and dictionary parameter passing. The nuances of mutable data and parameter passing are also explored. In summary, chapter five goes over all the necessary mechanics of defining functions so that programmers learn to modularize their code as they learn to program.
Kent D. Lee

6. Event-Driven Programming

Chapter six introduces event-driven programming. In an event-driven program, the program goes to an event queue to find the next event and then calls some code to process that event. Graphical User Interface (GUI) programs operate like this. Chapter six introduces event-driven programming using Tkinter, a graphical user interface library for Python programmers.
A widget is a GUI element that can be placed on the user interface of a windowing program. Tkinter includes support for many widgets including buttons, text boxes, frames, and labels. Layout is another important aspect of GUI programs. This chapter provides examples on how to use these widgets and layout directives. It provides a demonstration of the ideas through the development of a reminder application.
Kent D. Lee

7. Defining Classes

The final chapter draws the reader into defining classes. With this knowledge they are ready to build applications that combine Tkinter widgets with turtle graphics screens through the use of inheritance. It turns out that a turtle graphics screen is just another Tkinter widget. As an example, a simple drawing application is developed.
Other topics include polymorphism which is demonstrated using a bouncing ball example. The “self” reference is introduced and class definition and implementation in Python is covered. With the information covered in this chapter many interesting and fun final projects are possible including a blackjack game, an improved reminder application, an asteroids game, and an address book program, all of which are described in the exercises for this final chapter.
Kent D. Lee

Backmatter

Weitere Informationen

Premium Partner

BranchenIndex Online

Die B2B-Firmensuche für Industrie und Wirtschaft: Kostenfrei in Firmenprofilen nach Lieferanten, Herstellern, Dienstleistern und Händlern recherchieren.

Whitepaper

- ANZEIGE -

Best Practices für die Mitarbeiter-Partizipation in der Produktentwicklung

Unternehmen haben das Innovationspotenzial der eigenen Mitarbeiter auch außerhalb der F&E-Abteilung erkannt. Viele Initiativen zur Partizipation scheitern in der Praxis jedoch häufig. Lesen Sie hier  - basierend auf einer qualitativ-explorativen Expertenstudie - mehr über die wesentlichen Problemfelder der mitarbeiterzentrierten Produktentwicklung und profitieren Sie von konkreten Handlungsempfehlungen aus der Praxis.
Jetzt gratis downloaden!

Bildnachweise