Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Fundamentals of Programming: Using Python
Fundamentals of Programming: Using Python
Fundamentals of Programming: Using Python
Ebook257 pages1 hour

Fundamentals of Programming: Using Python

Rating: 5 out of 5 stars

5/5

()

Read preview

About this ebook

Why Python and why another Python book?
Simplicity. Python is one of the simplest programming languages I know. And I know several. Its syntax is intuitive. It enforces good style. It is so simple that one can ignore the language and focus on the problem to be solved.
After graduating with degrees in Economics, Law and Information Technology, and practicing law for 27 years, I now have my ideal job, teaching programming to some of the brightest beings in the universe, my students. I have had success in my classes, with students coming back again and again, taking any class I teach. But there is not enough room in my classes for everyone. I yearn to share my knowledge of and my passion for computers with many more students than could ever take my classes.
Hence this book. It is based on my lecture notes. I hope you will enjoy it. It is written in a friendly style that should encourage you to read it. Concepts are presented in "byte-sized" pieces to keep you from being overwhelmed.
LanguageEnglish
PublisherLulu.com
Release dateFeb 14, 2020
ISBN9780359909452
Fundamentals of Programming: Using Python

Related to Fundamentals of Programming

Related ebooks

Computers For You

View More

Related articles

Reviews for Fundamentals of Programming

Rating: 5 out of 5 stars
5/5

2 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Fundamentals of Programming - Bruce Embry

    Fundamentals of Programming: Using Python

    Preface

    Why Python and why another Python book?

    Simplicity. Python is one of the simplest programming languages I know. And I know several. Its syntax is intuitive. It enforces good style. It is so simple that one can ignore the language and focus on the problem to be solved.

    After graduating with degrees in Economics, Law and Information Technology, and practicing law for 27 years, I now have my ideal job, teaching programming to some of the brightest beings in the universe, my students. I have had success in my classes, with students coming back again and again, taking any class I teach. But there is not enough room in my classes for everyone. I yearn to share my knowledge of and my passion for computers with many more students than could ever take my classes.

    Hence this book. It is based on my lecture notes. I hope you will enjoy it. It is written in a friendly style that should encourage you to read it. Concepts are presented in byte-sized pieces to keep you from being overwhelmed. There are no useless exercises to promote rote memorization. Instead, each chapter has a glossary of key terms, and laboratory experiences that let you practice the concepts taught. Part A of each laboratory experience is an exercise in copying code. Copying verbatim is an essential step in learning programming concepts. Once you have copied the code and understand how it work, you are ready for Part B, which gives you the chance to be creative.

    Laboratory Experiences

    Go to YouTube.com, and search for What Most Schools Don’t Teach. Watch a 9-minute video featuring Bill Gates, Mark Zuckerberg, and many others, explaining why everyone should learn coding.

    Write a 1-2 page essay about what you are passionate about, and how computer programming can help you be more successful.

    Acknowledgments

    My wife, JoAnne has been my greatest coach and support in completing this book. She has been patient when I have been stuck, and my cheerleader when I have been distracted.

    The folks at Cognella have also been great. Without their support, this book would not have been possible, even though we parted ways before the book was finished.

    Neil Harrison at the Computer Science Department of Utah Valley University gave me the opportunity to teach Python to beginning students. My lesson plans formed the basis for many of the chapters.

    Michael Elliott, one of my favorite students, has been a passionate advocate for all things Python.

    Greg Baker, who has programmed in Python for over ten years, offered many helpful suggestions, above all, to make my code examples more pythonic.

    Chapter 1 – What is a Computer?

    Introduction

    Alan Turing, one of the founders of modern computer science, described a Universal Machine with the following characteristics:

    It stores and manipulates information.

    It is controlled by a changeable set of instructions

    Notice that he did not mention intelligence or thinking. Computers as they currently exist do not in fact think in the way that human beings do. They are a collection of on-off switches, arranged so that they can switch each other off and on. What can be done with on-off switches? In fact, quite a bit.

    Chapter Objectives

    After reading this chapter, students will understand:

    What a computer is;

    What binary arithmetic is;

    How computers can store and manipulate numbers, letters, and other forms of information;

    A brief history of programming languages;

    Why Python is such a popular programming language.

    Key Terms

    bit – short for binary digit. An on-off switch in a computer.

    binary – a numbering system based on powers of two. The numbering system used by computers.

    decimal – a numbering system based on powers of ten. The numbering system normally used by humans.

    hardware – the physical devices that comprise a computer system.

    hard disk drive – a storage device that consists of rigid platters which spin very rapidly

    solid state drive – a storage device that consists of flash memory chips

    software – the instructions which tell the computer what to do.

    machine language – instructions that computers can actually perform. Written as binary digits.

    assembly language – English-like instructions that correspond to machine language instructions. These are easier for humans to write and understand.

    assembler – a program that converts assembly language instructions to machine language.

    higher level language – a computer language that is more comfortable for humans to use. One higher level language instruction will correspond to many machine language instructions.

    compiler – a program that converts higher level language instructions into machine language.

    source file – a text file containing the instructions of a higher level language program.

    executable file – a file created by a compiler, which contains the machine language instructions that correspond to the source file.

    bug – an error in a program

    spaghetti code – a program design that resembles a plate of spaghetti. It is difficult to uderstand, follow, fix, or modify.

    operating system – a program that manages the hardware of a computer for other programs, so that they don’t have to. Examples:  Unix, DOS, Windows, MacOS.

    structured language – a kind of higher level language that uses blocks of code instead of GOTO statements. It is more immune to spaghetti code.

    string – a data type for handling letters and other characters

    interpretation – the process of reading, translating and executing source files in a single step.

    interpreter - a program which performs interpretation

    It’s all 1s and 0s

    Humans typically using a decimal system to represent numbers of almost any size. Decimal means ten. In a decimal system, we have ten digits, that we arrange in sequences from right to left. Each placeholder represents a power of ten. The right-most digit is 10⁰ or 1. The next digit to the left represents 10¹ or 10, and so forth.

    In a similar fashion, on-off switches can be used to represent numbers in a binary system. Binary means two. There are two digits, 1 and 0. The placeholders represent powers of two. For example, the numbers 0 through 9 can be represented in binary as:

    This way, any number can be represented by patterns of on-off switches. Bit patterns like this can be used to represent numbers, letters, graphics, sounds, videos, or anything else that we would like a computer to store and manipulate. But to the computer, they are just patterns of 1s and 0s.

    Hardware and Software

    A computer is composed of two separate but related systems. Hardware is the collection of physical devices that perform the computer’s functions. The hardware can be roughly divided into five classes:

    CPU – Central Processing Unit, which finds, loads, decodes and executes the instructions. It controls all the other parts of the computer. Commonly called microprocessor, or simply processor.

    MEMORY – a fast temporary storage location for programs and data. No program can be run and no data can be processed unless it is first stored in memory. When the computer is powered off, the memory is cleared. Most often constructed of DRAM chips (Dynamic Random Access Memory).

    STORAGE – a slower, more permanent storage for programs and data. Programs and data which are stored here remain when the power is turned off. This allows the computer to remember information from one session to the next. Traditionally implemented as a hard disk drive, but can also be a solid state drive, a USB drive, or an optical drive, such as DVD-ROM.

    INPUT – devices which

    Enjoying the preview?
    Page 1 of 1