ES112Lecture2 Iiitb
ES112Lecture2 Iiitb
PROGRAMMING USING
PYTHON
ES 112
A First Glance at Python
■ First run an interpreter: also called a shell
■ Objects
– Scalar : indivisible like atoms
– Non-scalar : internal structure
■ Scalar Objects
– int
– float
– bool
– None
Expressions in Python
■ 3 + 5 * 6
■ (3 + 5) * 6
■ English ■ Python
– Grammatically incorrect: – Syntax error
■ The moon green cheese ■ materialOfMoon 3.1416
– Grammatically inconsistent – Static (semantic) error
■ The moon are made of green ■ ‘green cheese’ / 3.1416
cheese – Dynamic Error
– No meaning in real life ■ circumference = pi * (diameter **
■ The moon is made of green 2)
cheese ■ materialOfMoon = ‘green cheese’
materialOfMoon / 3.1416
Would a Rose by any other Name Smell
as Sweet? pi = 3.1416
radius = 11
circumference = pi * (radius **2)
x = 3.1416
y = 11
z = x * (y**2)
pi = 3.1416
diameter = 11
circumference = pi * (diameter **2)