0% found this document useful (0 votes)
4 views25 pages

Python

This document introduces Python programming, detailing its characteristics, modes of operation, and basic syntax. It covers the structure of a program, the importance of good programming practices, and provides an overview of variables, comments, and operators in Python. Additionally, it explains how to use the Integrated Development Environment (IDLE) for coding in Python.

Uploaded by

shaiviupreti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views25 pages

Python

This document introduces Python programming, detailing its characteristics, modes of operation, and basic syntax. It covers the structure of a program, the importance of good programming practices, and provides an overview of variables, comments, and operators in Python. Additionally, it explains how to use the Integrated Development Environment (IDLE) for coding in Python.

Uploaded by

shaiviupreti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

CHAPTER-9

Chapter-10
Introduction
to
python
Program
A program is a set of step by step
instructions written in a computer language
for a computer to execute.
The sequence followed by computer program
is:
1.Read Input
2.Process
3.Store
4.Write Output
Characteristics of Good
program
• It should compile and run smoothy on
different platforms.
• A program should be easy to read and
understand, thus its maintenance will be
low.
• A good program takes less space and easily
converted to machine language.
• Program should be machine independent.
Introduction to
1. Python was createdpython
by Guido Van Rossum in late
1980’s at the National Research Institute for
Mathematics and Computer Science in the Netherlands.
2. Python is general-purpose, interactive, object-oriented
and high-level programming language.
3. It provides a structure and support for large programs.
4. It is processed at runtime by an Interpreter.
5. It can run on a varied range (Different platforms) of
hardware platforms with same interface.
6. Its source code is also available under the GNU General
Public License (GPL).
Introduction to
python
7. Python is deprived from many other languages, including ABC, Modula-
3 , C, c++, Algol-68, SmallTalk, Unix Shell and other scripting
languages.
8. Its code resembles the English language followed by fewer syntactical
constructions than other programming languages.
9. It provides very high dynamic data-types and supports dynamic type
checking.
10.It supports automatic garbage collection.
11.It is used for testing microchips, building video games with the PyGame
library,text processing, web applications, database applications, GUI
programs and for more.
12.Python is used by many organization such as NASA, YouTube and
Instagram.
13.It can also be used for writing Google Apps
Two modes of python

Interactive Mode

Script Mode
Interactive Mode
Script Mode
Difference between Two modes

Interactive Mode Script Mode


i. A way of using the python interpreter i. A way of using the python interpreter
by typing commands and expressions at to read and excuse statements in a
the prompt. script.
ii. Cant save and edit the code ii. Can save and edit the code.
iii.If we want to experiment with the code, iii. If we are very clear about the code,
we can use interactive mode. we can use script mode.
iv.We cannot save the statements for iv. We can save the statements for
further use and we have to retype all further use and we no need to retype
the statements to re-run them all the statements to re-run them.
v. We can see the results immediately. v. We can see the code immediately.
Steps to open interactive mode or IDLE
(Integrated Development Environment)
PythonWin is the first
Window Interface for
Python and is an IDLE
with a GUI .
1. Click the Start menu.
2. Click Python 3.4
3. Run the program , IDLE
(Integrated
development
Environment)
Let have some idea about how to
use IDLE…..
• IDLE is a text editor that
comes with Python.
• It helps to get code right.
• It also known as the
Python Interactive Mode.
• It is suitable for testing
instructions or code.
• The code that you want to
execute is typed after the
entry prompt (>>>)
• To run program in
Interactive mode ,press
Enter Key.
What is Error and Syntax? How they
are related to each other?
• Errors are also known as bugs.
• When the computer executes the
program and find mistake(s) it
shows error messages.
• Such mistake in the instruction or
code is known as Syntax error.
• Syntax is the structure of an
instruction in a computer
language.
• It is the grammar of a
programming language.
Steps to open script mode
• Click the Start menu.
• Click Python 3.4
• Run the program , IDLE (Integrated
development Environment)
• Once IDLE get opened.
• Click File New Window.
• A new blank window appears.
Let have some idea about
how to use IDLE…..
1. Open IDLE
2. Click File New Window.
3. A new blank window appears.
4. Now you can type codes in this
window
5. And save them for with filename
followed by .py extension name.
LINES AND
INDENTATION
Python provides no braces to indicate blocks of code. The
number of spaces in the indentation is variable, but all
statements within the block must be indented the same
amount. Asa result , in Python all the continuous lines
indented with same number of spaces form a block.
Comments in Python
Comments are important for adding essential information for another programmer to
read.
• Symbol hash (#) used for single line comment.
• Symbol quotes (“””) use for multiline comment .We have to type quote in beginning and
ending of the comment.

Using blank lines


Reserved Words

and exec not assert finally


or break for pass class
from print continue global raise
def if return del import
try elif in while else
is with except lambda yield
Variables
• Variable is the name that refers to a
place in the computer memory
where data is stored. But in python
variables do not need explicit
declaration to reserve memory
space.
• The declaration happens as soon as
value get assigned to a variable.
• The equal (=) sign is used to assign
values to variables.
• If a variable is not assigned a value,
error we be there.
Rules for naming a
variable
• Variable name should be descriptive.
• They should start with a lowercase letter.
• Programmer can separate the words with
underscore (_) followed by more letters,
underscores or digits (0 to 9)
• Python does not allow punctuation
character such as @ , $ and %.
• Spaces are not allowed either.
Examples of variable
names
Myvar2, MYVAR, myVar, _my_var , my_var,
myvar
• Valid Examples

2myvar, my-var, my var


• Invalid Examples
Multiple assignment
Python allows programmer to assign a single value to several variables simultaneously.

a=b=c=1 a,b,c=1,2, “RLB”


• An integer is created • Two integer with values
with the value 1 and all 1 and 2 are assigned to
three variables are variables a and b
assigned to the same respectively and one
memory location. sting with value “RLB”
is assigned to variable c
Mathematical
operators
Add
10
• 5+5

Subract 5
• 10-5

Multiply 200
• 10*20

Divide 2
• 10/5

Modulus (Remainder) 4
• 20%8

Exponent 8
• 2**3
Comparison Operators
Operator Meaning
== Equal to
!= Not equal to
> Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to

You might also like