Variables & Data Types

ECON 3209 · Week 1, Lecture 2 · Kerala Agricultural University

Department of Development Economics, KAU

Autumn 2026

Learning Outcomes

By the end of this lecture, you will be able to:

  1. Assign and name variables following Python conventions
  2. Identify and use the core scalar types: int, float, str, bool
  3. Create and manipulate list, tuple, and dict objects
  4. Convert between types and check types with type() and isinstance()

Variables

A variable is a named storage location in memory.

Python uses dynamic typing — you don’t declare the type; Python infers it.

Variable Naming Rules

Integers (int)

Floats (float)

Strings (str)

String Formatting (f-strings)

Booleans (bool)

Lists

List Methods

Tuples

Dictionaries

Dictionary Operations

Type Conversion

Checking Types

🏋️ Exercise

Create a Python dictionary for a cooperative society with these details, then compute and print the loan-to-deposit ratio:

  • Name: “Palakkad Primary Agricultural Credit Society”
  • Total deposits: ₹8,50,00,000
  • Total loans outstanding: ₹6,20,00,000
  • Number of members: 3,450
  • Year established: 1962

Print each detail with proper formatting. The loan-to-deposit ratio is loans / deposits.

Summary

Key Takeaways — Lecture 2

✅ Variables store data; Python infers types dynamically

Scalar types: int (whole numbers), float (decimals), str (text), bool (True/False)

Collections: list (mutable, ordered), tuple (immutable, ordered), dict (key-value pairs)

f-strings are the cleanest way to format output: f"GDP: ₹{gdp:,.0f}"

✅ Use type() to inspect, isinstance() to check types in code

Next Lecture

Lecture 3 — Operators & Expressions

We will cover: - Arithmetic, comparison, and logical operators - String operators - Introduction to None and truthiness - Building compound expressions for data filtering