Professional Documents
Culture Documents
Progress
in Python Interactive Mode
Python
Start Python Anaconda Navigator and then Spyder IDE. Or you may also use any other IDE of
your choice.
On the IPython console perform this session
~·
- ~-- 1:b• ~ ~I!,•~ )I ~ le~ t+ :Ii X ..,..,,......-~-
, > e- L_~ +_-:_~ ... +
"-'·,c-'.".....,,,,"""".,.,.,,.,,...._..,.___""
1
o -...,-a
- - ~ : • 1, •
.......
3 fl-uthor- : S u ai t •
•
6
7
In [1) , 6 • 3
0ut[1) , 18
Don' t worry if all the results are not clear to you right % gives remainder,
now. Just note down any questions arising. All these e.g. , 7"2 w ill give 1
doubts will be solved slowly when you learn the •• means raised to power
e.g., 23 is 2 • • 3
Python data handling concepts.
I= means Not equal t o
3
Chapter 6 : GETTING STARTED WITH PYTHON
1. 6 * 3 iS 15. a= 8 % 3 No eotpul
2. 3 ** 3 Jt 16. a
2
3 6+2*4 l'-1 17. 3**2**0 No Oufpuf
4. (6 + 2) * 4 3.2 1
18. (3 ,.,. 2) ,.,. 0
i
7. 9.0 ** 0.5
,.
so 21. 9.0 % 3 00
. l
_J -
PROGRESS IN COMPUTER SCIENCE WITH PYTHON _ XI
Displaying vs . Printing
Please note that writing an expression or variable name in front of the Python prompt
( In [ ]: ) displays its value e.g.,
when you assign a value or expression using = , Python
In [ ] : S = 23 ~ - - - - - - - simply does the assignment but does not show anything.
In [ ] : S result of S di&playn
23 : . - - - -
In[ ] : S + 3
. . , _ - - - - result of expression S + 3 di&playn
26
You can display values only in interactive mode ; to display anything through script
mode, you need to use print( ) command.
(Next PriP session 6.2 will make you practice print commands in script mode).
lri CJ : 3 3 + J 3
OuH J : 56
(ii)
ln [ J : 5 = .2 ~t9
p>Dn+ (s)
33
Chop_ter 6 : GETII NG STARTED WITH PYTHON
(m)
\n ( J : a ., 3
In( J : ~"' I i
In ( ) ·. c = Lr - I 0
Ifl ( J : f ,.tin+ Co , lr , c)
3 If 1.
,,.
I ', l
6 PROGRESS IN COMPUTER SCIENCE WITH PYTHON _ Xi
. Progress
in
· Python
Working in Script Mode
Start Python Anaconda Navigator and then Spyder 1l"/f)E. Or,you i,na~ qlso u~ any other IDE of
your choice.
1. Type following code (as it is) in the new window opened by IDLE
print (" Hello Nathan", "Hello Lalit ")
greetl = " Hello Nathan "
greet2 =" Hello Lalit "
namel = " Nathan "
name2 =" Lalit"
print (greetl, greet2)
print ("Hello", namel, ",", name2)
namel = " Purvi "
name2 = " Hunar "
print ("Helld', namel, ",", name2)
Save program file
Save the file by pressing Ctrl+S or File Save command
Run program
Click Run Run Module command or press FS.
You need not worry if certain things are not clear to you right now. Just watch out for
now ; everthing will become clear to you soon ©