Ch1.pptx
Ch1.pptx
Tulika
CHAPTER 1 Assistant Professor
PYTHON PROGRAMMING: AN Department of Computer Science
INTRODUCTION Miranda House
REF. BOOK- TANEJA, S. & KUMAR, N., “PYTHON
PROGRAMMING- A MODULAR APPROACH”,
PEARSON EDUCATION
INDIA, 2018.
PROGRAMMING LANGUAGE
A programming language is a set of instructions written by a programmer to deliver instructions to the
computer to perform and accomplish a task.
Examples are: Python, Ruby, Java, C , C++, C# etc.
Some of the key features of programming languages include:
Syntax: The specific rules and structure used to write code in a programming language.
Data Types: The type of values that can be stored in a program, such as numbers, strings, and booleans.
Variables: Named memory locations that can store values.
Operators: Symbols used to perform operations on values, such as addition, subtraction, and comparison.
Control Structures: Statements used to control the flow of a program, such as if-else statements, loops, and
function calls.
Libraries and Frameworks: Collections of pre-written code that can be used to perform common tasks and
speed up development.
WHAT IS PYTHON?
Python is an interactive programming language.
Simple syntax of the language makes Python programs easy to read and write.
Python was developed by Guido Van Rossum in 1991 at the National Research Institute for
Mathematics and Computer Science in the Netherlands.
Python is used in various application areas such as the web, gaming, scientific and numeric
computing, text processing, and network programming.
LANGUAGE FEATURES
Interpreted: There are no separate compilation and execution steps like C and C++. Directly
run the program from the source code. No need to worry about linking and loading with
libraries, etc. In an interpreted language, the code is executed line by line, while in a
compiled language, the entire code is converted into machine language before execution.
Platform Independent: Python programs can be developed and executed on multiple
operating system platforms. Python can be used on Linux, Windows, and many more.
Free and Open Source
High-level Language: In Python, no need to take care about low-level details such as
managing the memory used by the program.
Simple: Closer to English language; Easy to Learn
More emphasis on the solution to the problem rather than the syntax
1.1 IDLE – AN INTERPRETER FOR
PYTHON
IDLE stands for Integrated Development and Learning Environment.
Python IDLE comprises Python shell and Python Editor. While Python shell is an interactive
interpreter, Python Editor allows us to work in script mode.
While using Python shell, we just need to type Python code at the >>> prompt and press the
enter key, and the shell will respond with the result of the computation.
Python shell may also be used as a calculator, for example, when we type 18 + 5 followed by
enter, Python shell outputs the value of the expression, i.e. 23, as:
>>> 18 + 5
23
operator + acts on the operands 18 and 5. In the expression 18 + 5, + is called the operator.
The numbers, 18 and 5 on which the operator + is applied, are called the operands.
In general, an expression is a valid combination of operators and operands.
In Python, all forms of data are called values or objects. For example, 18, 5, and 23 are
objects.
Note: The result of division
27 / 5 is real number.
In Python, result of division is always a
real number.
However, if you wish to obtain an
integer result (for example, floor(5.4)),
Python operator // (two slashes without
any intervening blank) can be used.
Python operator % (percentage sign),
known as modulus, yields the remainder
of the division.