0 ratings 0% found this document useful (0 votes) 3 views 11 pages Getting Started With Python
The document discusses the importance of problem-solving in programming, emphasizing the need for a clear understanding of the problem and the logical sequence of instructions to solve it. It outlines the steps involved in problem-solving, including defining the problem, developing an algorithm, and implementing the solution through programming. Additionally, it introduces concepts like flowcharts and pseudocode as methods for representing algorithms, and briefly covers the Python programming language and its advantages.
AI-enhanced title and description
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
Save Getting Started with Python For Later
3.1 INTRODUCTION TO PROBLEM-SOLVING
Computers help us solve problems but they have no
intelligence or thinking power. A computer performs
many tasks but exactly in the manner as instructed.
However, before a problem can be tackled, we need to
understand the problem and the ways to solve it. So, in
order to instruct a computer correctly, the user must
have clear understanding of the problem to be solved.
y
Irrespective of the programming language being used,
the first and foremost thing while writing a program
is to analyze the problem well and try to solve it in a
logical manner. The process of writing a program is 3,1 Seminar pregramming
called ‘Programming’. Thus, when we write a program, we need to first clearly understand the
problem as well as its solution otherwise, we will end up writing incorrect or inefficient codes.
When we write a program, we are writing a set of instructions to solve a problem involving data
processing. These instructions must be executed by the computer to solve the problem. If the
instructions are correct and given in the right sequence, then the problem will be solved properly
by the computer. But if the instructions are incorrect or in the wrong sequence, then the problem
will not be solved correctly or will not be solved at all.
Therefore, writing correct instructions in proper sequence is extremely important. It means that
before we start writing a program, the steps for solving the problem should be clear in our
mind. Precise step-by-step instructions should be inputted to the computer system to solve the
problem. Thus, proper and flawless execution of any task inside a computer depends on how
correctly and precisely we define the problem (problem statement), design a solution (algorithm)
and implement the solution (program) using a programming language,
Therefore, problem-solving, is the process of identifying a problem, developing an algorithm
for the identified problem and finally implementing the algorithm to develop a computer
Program.
@ scanned with OKEN Scanner‘PROBLEM-SOLVING
‘or ealeulatin
eating marksheet 8
daylife, such a5
sin our day-t
her of probe
mn-solving mechanism.
i determining the cause of the problem. It
jem and determin
ober
require prpper P
and al problems req
ee ee galtermaties fora solution and implementing
Jc of defining 2
Problemesolving the ac of defini
also involves identifying prioritizing and
the slution,
ig. 32: Concept of Poblem Song
‘Wen problems ae straightforward and ess, we can nd solutions witout df a
Complex problem reaues a stent aproch to iding the it oon In REE War
‘we have to aply problem-solving techniques Problem-solvng starts with dearly defining the
problem and concludes with aflly operational slution inthe frm ofa program or sot
‘The ey steps required for solving problem usinga computer are shown n Fig 2.3 and discussed
inthe following subsections
Fig. 3.3: Sep for Problem Solving
3.2.4 Analyzing @ Problem
{tls important to clearly understand a problem before we begin to find a sotution to,
Stenot clear about what isto be solved, we may end up developing a program which
Tore Tener ead and analyze the problem statement carefully to
‘components ofthe problem and decide the
_ have: Byanalyzing a problem, we would be able tof
_8etept and the outputs that it should produce,
the
core functionalities that our solution should
igure out the inputs that our program should
tein ud tn Pun
‘Computer Selene wh thot!
pnt before writing program code fora given problem. The set of
Mracsented in natural language is called an algorithm. We ean imagine
‘well-written recipe for a dish with cleanly defined steps which, if followed,
h, We start with a tentative solution plan and keep on refining the
otureall apes ofthe desired ston for ven poems aoe
algorithm posible and we hae ste the not alec
eto convert the algorithm Ino a format which can be
erate the desired solution. Different high-level programming,
Hf program. It is equally important to record details of the
[document the solution. This is helpful when revisiting the
ereated should be tested on various parameters. The program should meet the
user. must respond within the expected time. It should generat the covest
all possible inputs. in the presence of syntactical errors, no output wil be obtained,
‘output generated is incorrect, then the program shouldbe checked for logieal errors,
oftware industry follows standardized testing methods like unit or component testing,
Eyration testing, systom testing and acceptance testing while developing complex applications
Mls 1s to ensure that the software meets all the business and technical requtements and
orks as expected. The errors or defects found in testing phase are debugged or rectified and
the program Is again tested. This continues til all the errors are removed from the program
Once the software application has been developed, tested and delivered to the user problems
«an still emerge, eq, functioning problems. These need to be resolved fram time to time, The
Imaintenance ofthe solution, thus, involves fixing the problems faced by the use, answering the
Aueries of the user and even serving the request for adation or modification of features
‘The given problem-solving stages help in developing computational thinking and, in tur, offer
proper, accurate and complete solution ta a given probletn,
3.3 ALGORITHM,
4m our day-to-day life, we perform activites by following a certain sequence of steps. Examples
of activities include getting ready for school, making breakfast, riding a bicycle, wearing ati,
solving a puzzle and so on, To complete each activity, we follow a sequence of steps.
‘Suppose the following steps are required for the activity of ‘riding aca’
1. Siti the driver's seat.
Put key in the ignition and star the car
Press the clutch and put gear in the correct position,
Move the car out ofthe garage.
‘Accelerate and start driving,
Use brakes whenever needed.
Stop on reaching the destination,
e—a
® scanned with OKEN Scanner‘the sum and
arcane 8 ne
vet
coer
Be wot ‘¢, from the user
en ie uber 8"
ser Pereira
Spe crane mtr eS
Sere Co eae ere Ma
Sep: So and
sep? El =
iar hat etc alow 35
er reared agen ded it
Serine sunt of me lr has 2 defi
| Sos mtr ts
sum =a+b+e
sum /3
sence of tps to accomplish a taSk. Such a fn
seth an algrti eeads to ex
es ‘beginning and a definite en,
pom trs peg fia 6 wr th comput
ser woes empress sores
ena tps
tomtom sed
step o programming, Once we have an alo
Compute program forgiving instructions to thc)
(nacfz deve! lnnuae the alors core, computer wil run the program correct)
chesney eae S082 orth so increase reliability, aeuraey an effi
at soe he lem anda al Ces phases—develping ofan 38
ely ener nce Ft no code. The later usualy ka
oi Te already present—it is ust a matter of
Peamiming language are adhered a
tang estes wet Pin
istles ofa good algorithm
eise (Well-defined inputs and Outputs): The steps are predic
ique (Clear and Unambiguous):
the inputs and the result ofthe p
nite:
tate
Results ofeach step are well-define
receding steps
‘The algorithm always stops after a finite number of steps
3pUS: The algorithm receives some inputs,
‘Outputs: The algorithm produces some outputs.
feasible: The algorithm should be;
id coding specifications.
Practically feasible tobe implemented intermsofdesiening
gorithm s independent of ny programming language an platiors
should define the prerequisite specifications for programming to solvea given task,
Wal-aeines]
independent Inputs
an Characteristics Wal-dtned|
ofan Algorithm Outputs
= "Gear
ns lvsambiguous
‘While writing an algorithm, itis required to clearly identify the following:
1, The input to be taken from the user.
2. Processing oF computation to be performed to get the desired result
3. The output desired by the user
9.4 REPRESENTATION OF ALGORITHMS
Software programmers apply their algorithmic thinking skills to examine the problem and
determine the logical sequence of steps required to obtain a solution. After identifying the steps,
itis necessary to write down these steps along with the required input and desired output. There
are two common methods of representing an algorithm-—flowchart and pseudocode.
3.4.1 Flowcharts—Visual Representation of an Algorithm,
Flowehart is the pictorial ——
Fepresentation of an algorithm, It is t
defined a a visual representation of
the sequence of steps and decisions
needed to perform a process/task. A | __}
Aowehart is used to represent how
8 program works. In other words,
a flowchart depicts the ‘low’ of @
program, Le, the breakdown of a
task into separate steps, as shown
fn Fig. 34. 1 shows all the steps of
process. Being a visual, it helps in
‘understanding the logic of a task quickly.
® scanned with OKEN ScannerCO —
managing @ Process or
‘ode. When translated this problem, we will ask the user to enter
Jeumenting OF
tesigning, 40 ec
aed im analyzing, designing SOT Tarts of the 35,4, b,c, respe three values, which get stored in three
‘hs, owls Oe chat eps Pee oe program I varan ect We wil then calulate the average ofthe threesarsles ad seve
program. speci Dats age, a owehart res Sine nally we wil ri the value sored in the variate aoe
Fa 3 FR beso draw towers: Some of ls see another example to create a flowchart
onchart
‘Tere are conmontysea Simba Shi
oe ed Net Ltd. plans to give a 7% year-end bonus to ea
ane ae Spe five a 7% year-end bonus to each of ts employees earning & 20,000 or
ae maining employees. Create a flowchart for
= vows, cated Connectors stow connection between dere caleulating the bonus for an employee.
erecta parts ofthe code, = ine.
ms pectngles show proce
aa aniloyams sow puts and OU
cjanans saw # decnicondlon (5 Na SEBS H
irate wes i.
re eps th ngen flow aos mul chs ape.
o Sonumaor Sy
Note You my use onlin diagram sofware drawio fr making flowcharts onlin.
Hove to Make aFlowehart
Fovechar mates a complicated processor task easier to understand. Thus, knowing how to as
ee
3.4.2 Peeudocode
Step 3: Add shapes and symbols,
‘Step 4: Connect your shapes wit lines and arrows Pseudocode is another way of representing an algorithm. It is used to express our logic,
‘Step 5: Spit paths or add decisions. Independent of any programming language. As the name suggests tis not areal coder iti an
‘Step 6: Customize the appearance of your flowchart {informal approach in English-like language about how to solve a problem.
‘Step 7: Dowload or share your flowchart. There are no rules associated with writing a pseudocode, It could be alist of instructions In
Englishclike language or in any programming language. Using it, we can easily break down a
Let us understand flowchart through afew examples,
nh afew examples bigger problem into smaller modules or sub-parts, which gives us better clarity about how
Example 1: to solve a particular program or a process. This can be explained using a real-life example of
Draw a flowchart to find the average of three numbers, ‘making a phone call from a smartphone. Another example is sending an astronaut to the moon
Ans, for navigation as shown in Fig, 35.
D— $$ sen no tape
Leite Oran apron ein les
[easter 73} sea etn for processing
Daw a paralelogram odie output
‘Sening an Astronaut he Moon ar
uno hone eee
20pm A
Erdem by using ol shape fig.25: amples of Preutocde
° eeepc ee ein Sad wn
Camper See wit 70"
e—a.
® scanned with OKEN Scannercet your code:
‘As is evident
3
the average of marks.
aan ses of 10 students and displays
sea pose
tos set 027
Sex marks oun
ens comter1
Then ea os a
urine
fa te yg lb 10
Display the average
de that reads mat
es than or equal £0 10
Example 4
Wiritea pseudocode
this name with “Hel
= ane = Anpue (TMB Y= YOU name?
pats print ("HeLLO™ + name)
‘ouput "Hl wsermame”
formal way afwiting programming code In English, There ae 0
“Ei reudocode is snple andi
standard rules to wie Pseudocode
3.5 DECOMPOSITION
Decomposition I the process of breaking dow
casily manageable pats. These smaller problems are solved one after the o
‘complex problem is solved
m a complex problem or system into smalles
ther until the big
a task? | [asks
Fig. 3.6 Decomposition Pocess
Ts tage involves breaking down the problem Into smaller components so that they 7
led easily The more we can break down a problem, the easier it i to solve.
Some real-life examples of the decomposition process are:
1. When we taste an unfamiliar dish and identi
eat deceposng tat cs its nda geen ae _
ual ingredients,
— :
hen we give someone
decompose a numb
PaSrI04610%3¢10%~7 10
4. P40
6. 2a
8
repeat for
By noting down the steps to solve a problem, we can often recognize patterns, And by
atterns. And by giving a
istof steps, we are one step closer to creating an algorithm,
3.6 PYTHON PROGRAMMING LANGUAGE
| > When we encounter the word Python, it reminds us ofthe flexible reptile.
However, the programming language has been coined ‘Python’ because
just. as the reptile has a flexible body, the language too is easy, simple and
Highly exe
®. pyt ae by alg wen asus In 299
fe the Navona Research instte [i
Mathematics and Computer Scene the Netherlands. is present owned by
Python Software Foundation (OP)
Python is based on the ABC language teaching lnguage crete replace. Gude an an
‘he programming language BAS which was developed eal
python sa general-purpose programming language hat can be wed ffectvly to bul any nd
TEvtonram that doe not rule direc aces to the computer hardware
Python is an open-source, object-oriented,
high-level programming language. It was
“CaM: Python is based on the ABC Tonguage and the name was inspired from the famous BBC comedy
show Monty Python’ Fing Ges.
YouTube, Netfix, Spotify, Dropbox, Instagram, et.
ng, GUL programming, Internet scripting/web,
‘commercial robots and in space and scientific
Python is used by Google search engine,
It is being widely used for system programmin
‘gaming, text processing, network programming,
applications.
ceo hpe —$——— ©
® scanned with OKEN Scanner“4 HigherProductivity:sincoPy
it offers higher productivity
Inoother words, you write
thon fsasimplelanguagewith small codesandextensive libraries;
'y to programmers as compared to languages lke C++ and Java
tess and get more done
55, Less Learning Time: Because of sin
and learn Python programming,
J) 6 GUL Programing: Python uppors Ut appleatonsthat canbe eaten pred to may
system calls, braries and Windows systems such as Windows MFC (Microsoft Foundation
| etl Pi
Class Library), Macintosh and the X Window system of Uni
|
] on 8 8.6.3 Limitations of Python
| | od ag fe at
|
|
|
|
It has become
ye syntaes meres
eqn ih si hy
sug Fetes reed "
peace
sss eat
ed Le
pon 20
poplar bees ple and short codes, es time i required to understand
‘of Libraries: It provides large standard libraries to solve a task.
8, Syntax Highlighting: I allows distinguishing between input, output and error messages by
different color codes.
programming languages, i has the following limitations
4. Speed: Python is slower than Cor C++. However Python sa high-level language, unlike Cor
C44; itis not closer to hardware,
Fig. 34sec Features of Python
2. Mobile Development: Fyton Is nota very god language for mabe development
so ieee Tica Ins seen as wealelangunge or mobil computing This the reason my vey ew nbs
| 1 btn upc enc epee ad we need n0t comple he pags applications ae bull ni
| before evctng I 3, Memory Consumption: Python s nota god choice for memoryintensive ass Due tothe
2 ties drumbalygpelsbjecorned programming language with few hey Realy ofthe data pen Phons memory consumpion los hgh
| atl ray a ee te arenes tac SReTEELS Ei stare acean Pinon bane wh dtm tre: a cna pp
3. Itis 2 free, open-source and portable language having a large repository of libraries. technologies like JDBC (Java Database Connectivity) and ODBC (Open Database
Connectivity), Python's database access layer Is found to be a bit underdeveloped and
primitive, It cannot be applied in the enterprises that need smooth interaction of complex
legacy data,
5. Runtime Errors: Python programmers have clted several issues with the design of the
language. Because the language is dynamically typed, it requires more testing and has
errors that only show up at run-time.
i 4, [takes ess time to develop Python programs as programs in Python are typlcally 3-5 i
\ shorter than equivalent programs written using ther object-oriented languages. Tiss
| because ofits builtin ighdevel datatype and its dynamic typing,
| 5. Mis excensible/extendabl and highly
‘ypes of variables or arguments
cient as theres no wastage of time in declan
\ ‘ feprrs lapses and ug colecton (better memory manag 3.7 INSTALLING PYTHON
2 iis easly compatible with other languages lik C, C++, Core ji :
« Honan ea oe Ever since the development of Python language, ft has been gradually becoming popular among
| |] tecture wes : =
We shall be working on Python 3.6.5; however, any 3x version can be used to implement Python
programming concepts. Before we start working, Python needs to be installed on our system,
To install Python, we must first download the Installation package ofthe required version from
the following lnk
sea ‘nps//[Link]/downlonds/
‘ndersan eve oncise and Engish-ike instructo®®
Programming background. nd 8" OY Bon programmen ee es
round, Sor people with no sub
4. Object oriented Pro People wi For instalation deal, sean
‘typed obj Framining Langua the given QR code,
Be: Its an inte ic
guage tECtve, interpreted andl dyn”
. i eh sre ih ten e
Conputer sinew —@
ietrletted programming
© scanned with OKEN Scannered Installer | — —
| [Easter rts serie Pon _ a
gython IDLE comprises two working nodes
{Gerint mode)
;
eter and Prete
python IDLE, Fon ee
rs yon as
Tis thon PCat thon Shell (Interactive mode) and Python Editor
IDLE)
erlopment Ue program that allowes the SET toe,
ace python Shell
sin diferent ways. IEcan be
cand pawerfl ile exploring its Interface,
ode or sat
sively, we ca
. voc
aeacively wes
run Pyto
rhe IDLE IDLE sas
Pon, The mes importa
Fan browse and debug Python P
To write and
sexing ons eon onthe deskzop oF men IED the
;
2.8.1 Python Sell
When we fist start Python IDLE
‘START menu > Apps BY name
the shel
Python Eaton <
‘on opening, Python Shell shows a welcome message displaying its version and a copyright
notice, After this, the command prompt (>>>) followed by a blinking cursor gets displayed,
‘which indicates that IDLE is now ready to take Python commands from the user (Fig, 39a)
irype "eopysight", "eredite or "Licensa()* for nore information
>>> | stare typing here
fpython 3.6.5 (v3.€,5:f88c0992b4, Mar 28 2018, 16107146) (MSC v.15) Welcome
| [Resa Fite)
(aren we open Pinna
trac, thon set wh prompt >>)
[sos crpiyed rte ert ee
recy nono
a
ae
Fg. 39Ia: teracve Python Shel
Learning Tip: Python shel
deplyg” >> "prompt to
inet that ie waite for 9
ter command tobe enced
This fs Python Shell, which is part of Python's Integrated
Development Environment. The thee ‘greater than’ signs (>>>)
are called the prompt or Python command prompt
3.8.2 Command Line interaction
‘When commands are entered directly in IDLE from the keyboard, the Interpreter/IDLE is said
Fig, 3.8 Sartng Python Shot
to be in interactive mode, In interactive mod, type the command "Hello World” in front of the
Python Shel san interactive
the same windows tie ae acer Ne We can type the Python code and see the output! _-PFOMPE(S>>) and press Enter to se what happens.
terface between Python commands and the OS.
¢———§—____ Computer Science with Prt 7 Biting started wan Pyton a a
© scanned with OKEN Scanneree ace mode, as snow in FE 3900)
i com Jo neract
fist
sand in Pt
We begin with 08
jon
practical lmpementat
shall
ts executed Immediately ang
rho
Tig br Orpayng Massae Fs
nt Ig
ns statemer
press Eater key after ping the fi
[Assoon as we press
the output is displayed
Alternatively this can be done ws
3910).
ini
print( fanetion, a5 show
ie tne)
a oe
ee tesco to
soya Mul Mesage sg pnt fection in Fython Shell
In the above case, we have glven two print) statements for displaying two diferent messi
upon presing Enter key
print) method
Wecan ge commands tthe pinay prompt ad se immedi ets, print 8 fans
‘eh dod spetied coten/resiton the see. The conten (cae argu
ts specited within he parentheses. Without any arguments, prnt() function simply jm?>
the next ine
Python sa case-sensitive language. Ths means that Python differentiates between the UPD
adloercase leer, Fr example, Print (P uppercase) and prit(p lowercase) are to ae
things for Python. While print abun method in Python, Prints just aword and not 2
command, Tis canbe absered by typing the command Pin ("elo World").
Tecaiesrnypectecomantcne eae ae
= ———
tating sea wt ton
AMnot beable to interpret it and will show an error as shown in Fig. 3.9 ¥
ig. 3.90: Eror on Typing Print instead of print)
We must remember that while using print() command, the message or the argument to be
Aisplayed shouldbe placed within quotation marks (single ' * or double") the argument ie
then displayed as itis,
If the argument is not placed within quotation marks, then the interpreter tiesto evaluate the
argument and displays the result: This feature Is used to perform calculations. If we give an
arithmetic expression as an argument, the interpreter shows it valu. Ths is shown in ig 39(e)
Practical implementation-2
Using IDLE asa Calculator like text/string messages we have given so far, we can also perform
‘mathematical calculations using Python command prompt.
Fig 3 9(¢: Evaluating Athmetc Expressions
In the given statements, we have performed mathematical calculations using prin() statement
as well as by directly typing the command without the use of print() command. In either of
the cases, these statements are immediately executed by Python interpreter and the output is
Aisplayed within a fraction ofa second.
{CIM To repent a command in IDLE, press A+ Pto save line and ypina eon
Note: print() function will convert the argument or message Into string before writing to the
Consecutive arguments are separated by commas in print) function. When print() Is executed,
the values of consecutive arguments are separated by a space between them. We can say that
‘pace Is the default separator of values in the output. We can specify a custom separator for
Printed values using the sep argument in the print) function. (Fig, 3.9(8),
® scanned with OKEN Scanneree. ) abl Fin Sho
epet enor 4 Bon Shel Window (as shown in Fig. 39a) comprises menus (Fle, Edit etc) and a Python
tot atten oe sa ono >» whee yuan ype reer serene ees ae
sya aes Gul erento compron wo athr inte way hat halls ee ee
et eee se ta tne standard output device SSA oct copy and past carer commands/statements en to modly the
inse st value, def jects OF
si ‘ont
vie oo
saute atribute
Python Shell window has the following menu items—
{Speer rete or stewmnte to
ono
Fig. 3.10; Python Shell Window
File menu provides different o
Browser, Path Browser, Save, Save As, Save Copy As, Print Wi
Edit menu allows us to eit the text we type inthe Shel by a
‘5 Undo, Redo, Select Al, Cut, Copy, Paste, Find, Replace,
Shel and Debug menus are useful when creating larger programs. Shel
to restart Shell or search Shell's log to trace the most recy
Useful menu items (or debugging Python program
line-by-tine execution ofthe entered Python statements
Options menu allows the user to configure IDLE ace
shortcut ample, changing font style of Python Shell window hig
shortcut keys, etc
=
me
et be specified afterall the values y
rat then t mst be ven as follows:
to spel the sparta, en an example
se weuse sep argue take
be printed Otherwise, the interpreter shows & 51
fee Error
iows keyword axgunent,
Pythons print) function comes witha parameter/angument called ‘end’ By default, the value Window menu allows the user to rear
i ih parameter y default, the value
sprint fanetion
sment with any characte Help option provides Python help and a
«new Tine character We can end a print statement with any charac "thon ely
this parameter Is" Le, new eee
tise eaten after the last argunnt tow (we
he ctw pine to spate he anumens and ed after the Lv me | 7
For eal, pete loving sateen ang ‘ed! parameter
150, 20,30, sep = 80)
locumentation,
19 In Script Mode)
>>> print "cow", teat", ‘dog, sep=",', end
and press Ener key
‘mode in which we can save the commands we
Python Shell will execute It and display the output, 2s shown in Fig. 3.9(g):
‘Step 4: Creating Script/Program Fite
file menu provides various options to create a new
oe the current module/session,
os) ere
le open an existing file, o
Fig. 3.919: Use of tnd parameter with, print) ee
ha *———___ Computer Sxence mt? estes
EE
© scan
File, Edit, Shell, Debug, Options, Windows
and Help. ™
© commands, along with their output,
fon can be overcome by working
tions such as New File, Open, Open Module, Recent Files, Module
indow, Close Window and Exit {DLE.
ipplying various editing options such
I menu allows us
nt reset. Debug menu provides
in order to trace errors while checking for
ording to the suitability and working
lighting code color,
ge windows and select the active window.
get cleared
i in Python Seript
pen a module, save
'w File option (Fig. 3.11(a)), a new window
which is a simple and standard
€ ofits opening, this file window
°—_—a-
ned with OKEN ScannerEner are ah which
youhavetosoe hee
oe org with he eensen oy
ig. 3.110 Saving file wih py Exenson
en ie forget 9 gy o py extension wie saving th
sion wile sving he Mle for the rt ine, ton
‘editor automatically gives the extension along with the file name. di
‘Step 3: Running Script/Program File
‘To execute a Python Srp le, we have to choose Ran Module opin rm Ran enor press
the function key F5 (Fig. 3.11(e)). 5
More about Script Mode
‘While working inthe script mode, when we enter the statements to be executed and
ch 5 sments to be executed and press
Enter key, we won't automatically see the results the way we would seein the Interactive
‘mod. To see output from a script mode, we have to run this script and/or invoke
pe Te pt and/or invoke print()
Fig. 3:11 Type the Commands in New Bank le Seri Moe)
‘Step 2: The next step isto save this ile by clicking on File menu -» Save As option, followed by Sse os
‘yplng a proper name fori in lew ofthe default name ‘Untied: eaves Se mas
ig. 3.11 Running the Fle
etc iyeten script ms")
eters is strostageous ewer antersceiv9 note
etre saves the seatecens Cypee lng this made")
Fig. 3.11: Output athe Program dplyed ade Prihon Shell
e—a—
® scanned with OKEN Scanner
* anton sae wn yen
re sce vin 90¥..
and all outpot lines are
| ofthe ourput obtained. tence,
member, evenfwe enter
Python shell Aso, ll commands are given to
3.9 EXITING PYTHON
1m order to ext the Python command prompt,
‘quit() oF exit() built-in function and press Enter key.
ext or quit) doesnot wrk then aeratively you cn type the following commands:
mode te output shall be espayeg,
in statment insert o
ee wether inthe form of a module/progran gen”
mderadng Sa dary
mye opeter wah fers beter ond =
spayed wets ppbeveen command and outtake le
ees Cris shortcut key combination opty,
ee)
‘Algor refers tothe reo alow tose a problem
‘An algorithm i defied 2 3 step-by-step procdur desgned to perform an operation which et
510:he deg
‘Algortims have defi begining a definite end and a tte numberof tps
‘00d algorithm, which specie uniue and ire receves input nd produces an output
Aflowchar isa typeof agram tha represents the aborthm raphislly sng Boxes of aris Hod, nan aie,
onnectoa by aos
‘An slot where exch step is xeited one fe the thei sd to be enceuted in a sequence,
Dedsionmatng moles election of ne ofthe aerate bated on outcome of contin,
‘There can be mre than one approach to soles protien. Hence, we an have more than one seo fs
partulapotiem.
The hee of algorithm should be made onthe bs of tne and space comple.
‘complete set ofistuctions witen wing programming nage tered asa Progran/CodeProgran Cole
yon 2 powerful and exible programming anguage it wes con nd easytolear syntax which ns
rogrammers to write more codes ana develop mare corlex pops ines Ue,
Pythons 3 platform independent programing lngueee.
Frthon interpreter executes one statement (command) sane,
Friton roids two ferent ways to werk lth—Interactie mode and Sct mode
Interactive mode doesnt ste command
‘1s diloyed as soon awe pres Et
+ Inthe form of program andthe output placed between con
le key after typing ane or more commands
Interactive mode is site for testing code.
Prion sa caresenstive language Tha, Pitan
Pon san interpreted anvage
thon’ ntractve interpreter i as called ython Shel
Protrams writen in Python ae easy eadsble and understandable,
peste tt sree nn
Serst made stl for resting programs and then running se mike
Pit aretwo diferent etfs in Python.
them ater and getting complete utp
‘ =, ‘Computer Scienos wih Fs
sete td ty
whch iets eed
Prthon was develope
‘as rut,
: he lote 1980
a Prozramming one
(0 tm Python =
oy alt 3 Emer keys pressed, Me iMterpreter
(© dea, enon
‘The statement prin fering
by Gide van
6,
Fost a0.
vbr function ky suse
0
0 On execution
(8 t= 10) walverunie
‘ure top dc
the statement print a
EINE ("Wozkingesmuaencese ee
(8 Tre parameter. ie)
np oF int eon ed get
(0. Error ina program is termed a
State whether the followin
(9) Ging comment
(©) without any argument,
i hese
(8 thon ues completo
(2) Thesatement nny =
©) testonet rine
”
0
o
510 the net ne,
sedtoodtthefleinwe
nd ‘ent parameters canbe wed to
1 ne ra do change the way in which the corns of pint meted
(8) 8 detou, prin) mato ends ths new ie
() When we 52 operatar athe
sen we: ‘eptrator among te vals, the values at dled wth a pce
3 Mute Chlee Quetions (cas
(9) Which symbol ee ory
(0 cre
(i) Rectangle
(i) oismene
lw) Pralogram
Present procesenginfowehas?
e—a-
A reeemmee CSI
® scanned with OKEN Scanner