Introduction to Python Programming
eBook - ePub

Introduction to Python Programming

  1. 444 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Introduction to Python Programming

About this book

Introduction to Python Programming is written for students who are beginners in the field of computer programming. This book presents an intuitive approach to the concepts of Python Programming for students. This book differs from traditional texts not only in its philosophy but also in its overall focus, level of activities, development of topics, and attention to programming details. The contents of the book are chosen with utmost care after analyzing the syllabus for Python course prescribed by various top universities in USA, Europe, and Asia. Since the prerequisite know-how varies significantly from student to student, the book's overall overture addresses the challenges of teaching and learning of students which is fine-tuned by the authors' experience with large sections of students. This book uses natural language expressions instead of the traditional shortened words of the programming world. This book has been written with the goal to provide students with a textbook that can be easily understood and to make a connection between what students are learning and how they may apply that knowledge.

Features of this book

  • This book does not assume any previous programming experience, although of course, any exposure to other programming languages is useful
  • This book introduces all of the key concepts of Python programming language with helpful illustrations
  • Programming examples are presented in a clear and consistent manner
  • Each line of code is numbered and explained in detail
  • Use of f-strings throughout the book
  • Hundreds of real-world examples are included and they come from fields such as entertainment, sports, music and environmental studies
  • Students can periodically check their progress with in-chapter quizzes that appear in all chapters

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Introduction to Python Programming by Gowrishankar S,Veena A in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming Games. We have over one million books available in our catalogue for you to explore.
1
Introduction
AIM
Setup a Python development environment and understand the importance of Open source software and its different licenses.
LEARNING OUTCOMES
At the end of the chapter, you are expected to
• Identify various domains where Python plays a significant role.
• Install and run the Python interpreter.
• Create and execute Python programs using PyCharm IDE and Jupyter Notebook.
• Understand the meaning of Open Source Software and its different licenses.
Python is a free general-purpose programming language with beautiful syntax. It is available across many platforms including Windows, Linux and Mac OS. Due to its inherently easy to learn nature along with Object Oriented features, Python is used to develop and demonstrate applications quickly. Python has the “batteries included” philosophy wherein the standard programming language comes with a rich set of built-in libraries. It’s a known fact that developers spend most of the time reading the code than writing it and Python can speed up software development. Hosting solutions for Python applications are also very cheap. Python Software Foundation (PSF) nurtures the growth of Python programming language. A versatile language like Python can be used not only to write simple scripts for handling file operations but also to develop massively trafficked websites for corporate IT organizations.
1.1 What Is a Program?
The ability to code computer programs is an important part of literacy in today’s society. A program is a set of instructions instructing a computer to do specific tasks. “Software” is a generic term used to describe computer programs. Scripts, applications, programs and a set of instructions are all terms often used to describe software. The software can be categorized into three categories,
System software includes device drivers, operating systems (OSs), compilers, disk formatters, text editors and utilities helping the computer to operate more efficiently. System software serves as a base for application software. It is also responsible for managing hardware components.
Programming software is a set of tools to aid developers in writing programs. The various tools available are compilers, linkers, debuggers, interpreters and text editors.
Application software is intended to perform certain tasks. Examples of application software include office suites, gaming applications, database systems and educational software. Application software can be a single program or a collection of small programs. This type of software is what consumers most typically think of as “Software.”
There are myriad of areas where programs are used like supermarkets, banks, insurance industries, process control, hospitals, offices, government institutions, education, research, telecommunication, transport industry, police, defense, multimedia applications, entertainment systems, library services and many more.
1.2 Programming Languages
Computers cannot write programs on their own as they don’t understand human needs unless we communicate with the computer through programming languages. A programming language is a computer language engineered to communicate instructions to a machine. Programs are created through programming languages to control the behavior and output of a machine through accurate algorithms, similar to the human communication process.
1.2.1 Machine Language
Machine language, also called machine code, is a low-level computer language that is designed to be directly understandable by a computer and it is the language into which all programs must be converted before they can be run. It is entirely comprised of binary, 0’s and 1’s. In machine language, all instructions, memory locations, numbers and characters are represented in 0’s and 1’s. For example, a typical piece of machine language might look like, 00000100 10000000.
The main advantage of machine language is that it can run and execute very fast as the code will be directly executed by a computer and the programs efficiently utilize memory.
Some of the disadvantages of machine language are,
• Machine language is almost impossible for humans to use because it consists entirely of numbers.
• Machine language programs are hard to maintain and debug.
• Machine language has no mathematical functions available.
• Memory locations are manipulated directly, requiring the programmer to keep track of every memory location.
1.2.2 Assembly Language
Machine language is extremely difficult for humans to read because it consists merely of patterns of bits (i.e., 0’s and 1’s). Thus, programmers who want to work at the machine language level instead usually use assembly language, which is a human-readable notation for the machine language. Assembly language replaces the instructions represented by patterns of 0’s and 1’s with alphanumeric symbols also called as mnemonics in order to make it easier to remember and work with them including reducing the chances of making errors. For example, the code to perform addition and subtraction is,
ADD 3, 5, result
SUB 1, 2, result
Because of alphanumeric symbols, assembly language is also known as Symbolic Programming Language. The use of mnemonics is an advantage over machine language. Since the computer cannot understand assembly language, it uses another program called assembler. Assembler is a program that is used to convert the alphanumeric symbols written in assembly language to machine language and this machine language can be directly executed on the computer.
Some of the disadvantages of Assembly language are,
• There are no symbolic names for memory locations.
• It is difficult to read.
• Assembly language is machine-dependent making it difficult for portability.
1.2.3 High-Level Language
High-level language is more like human language and less like machine language. High-level languages are written in a form that is close to our human language, enabling programmers to just focus on the problem being solved. High-level languages are platform independent which means that the programs written in a high-level language can be executed on different types of machines. A program written in the high-level language is called source program or source code and is any collection of human-readable computer instructions. However, for a computer to understand and execute a source program written in high-level language, it must be translated into machine language. This translation is done using either compiler or interpreter.
Advantages
• Easier to modify, faster to write code and debug as it uses English like statements.
• Portable code, as it is designed to run on multiple machines.
A compiler is a system software program that transforms high-level source code written by a software developer in a high-level programming language into a low-level machine language. The process of converting high-level programming language into machine language is known as compilation. Compilers translate source code all at once and the computer then executes the machine language that the compiler produced. The generated machine language can be later executed many times against different data each time. Programming languages like C, C++, C# and Java use compilers. Compilers can be classified into native-code compilers and cross compilers based on their input language, output language and the platform they run on. A compiler that is intended to produce machine language to run on the same platform that the compiler itself runs on is called a native-code compiler. A cross compiler produces machine language that is intended to run on a different platform than it runs on.
Not all source code is compiled. With some programming languages like Python, Ruby and Perl the source code is frequently executed directly using an interpreter rather than first compiling it and then executing the resulting machine language. An interpreter is a program that reads source code one statement at a time, translates the statement into machine language, executes the machine language statement, then continues with the next statement. It is generally faster to run compiled code than to run a program under an interpreter. This is largely because the interpreter must analyze each statement in the source code each time the program is executed and then perform the desired conversion, whereas this is not nec...

Table of contents

  1. Cover
  2. Half Title
  3. Title Page
  4. Copyright Page
  5. Dedication
  6. Table of Contents
  7. Preface
  8. Acknowledgment
  9. Authors
  10. 1. Introduction
  11. 2. Parts of Python Programming Language
  12. 3. Control Flow Statements
  13. 4. Functions
  14. 5. Strings
  15. 6. Lists
  16. 7. Dictionaries
  17. 8. Tuples and Sets
  18. 9. Files
  19. 10. Regular Expression Operations
  20. 11. Object-Oriented Programming
  21. 12. Introduction to Data Science
  22. Appendix-A: Debugging Python Code
  23. Bibliography
  24. Solutions
  25. Index