You are on page 1of 3

Chaper GETING STARTED WITH PYTHON

P = 2+3 in front of
[Caretully notice, when you assign an expression to e.g.,
a name
and
prompt In ]: does Python display anything ? When does Python display
when not ? ]

Result (what Result (what


Expression
Python retums) Expression Python returns)

1. 6 3 15.

s3 16

62*4 17. 3 2 0

(6 2)*4 18 (3** 2) ** 0

5. 5 - 3 - 3
19 a+5

b. k 5 (3 -

3) 20. 3.0* 0.5

7. 19.0** 0.5
21 9.8 %3
8. (5+3.1) 5
22.-9.0%4
9.
S 5.0-(3 -3.0) 23. 6.2 %4

10. S
24. 2 5

11. x = 12.0 4
25. 3 5 and 5 < 3

12.
26. 4 3 or 6> 7

13. 7 -7 - -7 27. 3 3

14. 8/6
28. 4 ! = 5
PROGRESS IN COMPUITR CIENCE
WITH PYI ON

Displaying vs. Prinling


Please note that writing an expressiorn or varlable náme in front of the Pvtthon rompt

(In | )displays its value r,g, when you dslgon a ahe or expreaalon uainM, Pytem
aimply does the asalg1nnient but doen not show anything
Inl ]: S-23
In[ :S renult of S diaplayed
23
In[ ]: S +3 result of expresion 8+ diaplayed
26

P'rinting is done with print () function call command e,8

In[ 1: print (S+ 3)


reult of St I printed
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).

2. Display and print the given values


() 33+ 23

(i) S 24+9 (first assign 24 +9 to S and then print (display S))


(ii) a 3, b 17, c =b 10 (first assign these values to a, b and c in three
-

tatements and then separate


print/display them.)
(i)

(i)
(ii)

You might also like