Python Programming for Complete Beginners: A Structured Course

Lesson 2: Data Types & Operators

Objective: Understand Python’s basic data types.

  • Strings ("text"), integers (5), floats (3.14) etc.

  • Arithmetic (+-*/) Operators.

  • String concatenation ("Hello" + "World").

 

Casting

If you want to specify the data type of a variable

x = str(3)    # x will be ‘3’
y = int(3)    # y will be 3
z = float(3)  # z will be 3.0

 

Code Example

[1] Print the data type of the variable x:

x = 5
print(type(x))
 
[2] operator to add together two values:
print(10 + 5)
 

Exercise:

  • Calculate the area of a rectangle (length × width).