Chapter5 Getting Started With Python
Chapter5 Getting Started With Python
3)Interactive mode :- It is a command line she which gives immediate feedback for
each statement. While running previously fed statement in active memory
7) Dynamic type - language :- In python , the user does not need to define the data type
of each of the variable used in the code as by default , the system defines the data type
.Fir ex :- If a user enter two variable A=25 , B =10Then , when the sum 'a' and 'b' is
calculated , it will result in 35 . Then , system has by default defined the data type as
integer .
8) Completeness :- Support wide range of library
9)GUI programming support :- Graphical user interface can be made using a module such
as py qt5 , py qt4 , wx python or thinker in python.
like the other programming languages, Python also has some limitations. Some of
them are mentioned below:
Simplicity:-
Python is one of the simplest programming languages, which can indeed be a
problem. Its syntax is very simple and makes a programmer more of a Python
person. As a matter of fact, the users becomes so accustomed to its features that
they might feel it tougher to learn or work on other programming languages.
Weak In Mobile Computing:-
Python is a very simple programming language. The developers always need to write mobile apps
in a particular programming language according to the mobile platform. the developers prefer to
use Python directly for developing mobile apps because of its slow speed. Thus, it is very rarely
used for apps development.
Application Portability:-
installation of a specific version of Python interpreter on the operating system is needed to run
the application on that platform. Thus, the developers face problems in porting the application
from one platform to another.
Algorithms:- The last and final final stage where step by step
instructions to be followed for finding the solution of the
problem
Decomposition For ex:- we have to find sum if all the numbers from 1
to 100 To make it easy we can do 1+2+3+4...................97+98+99+100
Algorithm:-Step-1 Start
Step-2 Sum the lowest and highest numbers
Step-3 find Number of terms and dividing the highest number by 2
Step-4 Multiply step 1 & step2
Step-5 Display the result
Step-6 Stop
What is Problem Solving?
Problem solving is the process of identifying a problem, analyze
the problem, developing an algorithm for the identified problem
and finally implementing the algorithm to develop program.
There are many standard software testing methods used in IT industry such as
• Component testing
• Integration testing
• System testing
• Acceptance testing
What is Algorithm?
• A set of precise, finite and sequential set of steps written to solve a problem
and get the desired output.
• Algorithm has definite beginning and definite end.
• It lead to desired result in finite amount of time of followed correctly.
What are the points that should be clearly identified while writing Algorithm?
• The input to be taken from the user
• Processing or computation to be performed to get the desired result
• The output desired by the user
Representation of Algorithm
An algorithm can be represented in two ways:
• Flow chart
• Pseudo code
Flow chart
• Flow chart is visual representation of an algorithm.
• It's a diagram made up of boxes, diamonds and other shapes, connected by arrows.
• Each step represents a step of solution process.
• Arrows in the follow chart represents the flow and link among the steps.
Flow Chart Examples
Example 1: Write an algorithm to divide a number by
another and display the quotient.
Algorithm
Step 1: Input a two numbers and store them in num1
and num2 Step 2: Compute num1/num2 and store its
quotient in num3
Algorithm
Step 1: Input a number and store it to num.
Step 2: Compute num * num and store it in square.
Step 3: Print square.
Pseudo code
INPUT num
COMPUTE square = num*num
PRINT square
Flow of Control
An algorithm is considered as finite set of steps that are executed in a sequence. But
sometimes the algorithm may require executing some steps conditionally or
repeatedly. In such situations algorithm can be written using
• Sequence
• Selection
• Repetition
Selection
Selection in algorithm refers to Conditionals which means performing operations
(sequence of steps) depending on True or False value of given conditions. Conditionals
are written in the algorithm as follows:
If <condition> then
Steps to be taken when condition is true
Otherwise
Steps to be taken when condition is false
Algorithm, Pseudocode, Flowchart with Selection (Using if)
Examples
Example: write an algorithm, pseudocode and flowchart to
display larger between two numbers
Input, Process and Output Identification
INPUT: Two numbers to be compared
PROCESS: compare two numbers and depending upon True and False value of
comparison display result
OUTPUT: display larger no
Algorithm
STEP1: read two numbers in num1, num2
STEP 2: if num1 > num2 then
STEP 3: display num1
STEP 4: else
STEP 5: display num2
Pseudo code
INPUT num1, num2
IF num1 > num2 THEN
PRINT "num1 is largest"
ELSE
PRINT "num2 is largest"
ENDIF
Flow Chart:-
Repetition
• Repetition in algorithm refers to performing
operations (Set of steps) repeatedly for a given
number of times (till the given condition is true).
Repetition is also known as Iteration or Loop
Repetitions are written in algorithm is as
follows:
Pseudocode
SET count = 0
WHILE count<10
PRINT "Techtipnow"
Count = count + 1
END WHILE
FLOWCHART:-
Decomposition
• Decomposition means breaking down a complex problem into smaller sub problems to solve them
conveniently and easily.
• Breaking down complex problem into sub problem also means analyzing each sub problem in detail.
• Decomposition also helps in reducing time and effort as different subprograms can be assigned to
different experts in solving such problems.
• To get the complete solution, it is necessary to integrate the solution of all the sub problems once
done.
Step 1Click IDLE (Python 3.8 32-bit) icon which is available on the Start
pop up screen.
OR
On the desktop
OR
If pinned to the taskbar.
Script Mode
Script mode refers to the mode where the user is
able to execute multiple commands or statements
simultaneously.
How to work in Script mode
Step 1Click IDLE(Python version 3.8 32-bit) icon
which is available on the Start pop up screen.
OR
On the Desktop
OR
If pinned to the Taskbar
Step 2
1. Click 'File’
2. Select New 'File’ An Untitled Window will appear.
This window provides the user a Platform to write
programs on it
Step 3
Type a Code in the 'Untitled' window to program file.
Step 4
1. Click 'File’.
2. Select 'Save As’.
Step 5
Select the File, where you want to save the Program File
on you Computer.
Step 6
Enter the File name (say Num) in the 'File name' text box.
Step 7
Click on 'Save' button.
The File will be saved in the system with the extension .py
(by default).
Why Script Mode?
Note:-
When you run a program, the output will be available on the Interactive window.