Introduction to Python Programming
eBook - ePub

Introduction to Python Programming

Gowrishankar S, Veena A

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

Introduction to Python Programming

Gowrishankar S, Veena A

Book details
Book preview
Table of contents
Citations

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

How do I cancel my subscription?
Simply head over to the account section in settings and click on ā€œCancel Subscriptionā€ - itā€™s as simple as that. After you cancel, your membership will stay active for the remainder of the time youā€™ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlegoā€™s features. The only differences are the price and subscription period: With the annual plan youā€™ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
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.
Do you support text-to-speech?
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.
Is Introduction to Python Programming an online PDF/ePUB?
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 & Computer Science General. We have over one million books available in our catalogue for you to explore.

Information

Year
2018
ISBN
9781351013215
Edition
1
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