18-Introduction to Python-Basics, DataTypes
18-Introduction to Python-Basics, DataTypes
Session – 16
Ahmedabad University
Topics to be covered
❑ Introduction to Python
❑ Basics of Python Programming
❑ Understanding Python Shell
❑ Comments, Variables
❑ Rules for defining variables
❑ Python Data Types – integers, float, string,
collections
Introduction to Python
Introduction to Python
Demonstration using
Python 3 IDLE Shell
Introduction to Python Programming
Demonstration of Python 3 IDLE Shell
Python - Comments
Comments in Python
studentMarks = 0
Variables in Python
A variable can have a short name (like x and y) or a more descriptive
like (age, studentName, totalVolume).
rollNo = 101
studentMarks = 90
studentName = ‘KP’
Variables in Python
Boolean Values
In programming you often need to know if an expression is True
or False.
You can evaluate any expression in Python, and get one of two
answers, True or False.
Examples
print(10 > 9)
print(10 == 9)
print(10 < 9)
True
False
False
Python Booleans
Examples
When you run a condition in an if statement, Python returns True
or False:
a = 200
b = 33
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")
Data Types in Programming
Python Data Types
Example:
marks = 85
rollNo = 2019101
Python Data Types
Floating point
More popularly known as float, which refers to numbers that
have decimal parts. Examples are 12.34, 0.001, 0.050,
101.001.
Example:
studentHeight = 5.75
studentAge = 21.5
Python Data Types
String
String data type is used to store text. To declare a string variable, you can write
any of the following syntax
or
Example:
StudentName = ‘K Patel’
StudentAddress = “Ahmedabad, Gujarat, India”
studentAge = ’25’
>>> 11 / 2
>>> print(10 == 9)
>>> print(10<8)
Demonstrations
Topics covered and References
Introduction to Python
Basics of Python Programming
Comments
Variables
Rules for defining variables
Python Data Types
https://docs.python.org