Python Variables, Data Types and Operators: Beginners Guide Episode 3 (Updated June 2026) (Updated June 2026)
Variables and data types are where every programming journey begins — and Python makes this starting point more accessible than any other language. What most people don't realize is that the NASSCOM-Deloitte 2025 report projects 1.25 million AI and data-skilled professionals will be needed in India by 2027, and Python sits at the centre of that demand: it's the language of data pipelines, machine learning, web automation, and API backends. TCS laid off 12,000 employees in mid-2025 citing automation of routine tasks — and simultaneously posted 18,000 Python and data engineering openings. The engineers who stayed ahead were those who understood Python at a fundamental level. Episode 3 of our Python Essentials series covers the building blocks: variables, the four core data types (int, float, str, bool), type conversion, and all three categories of operators. Understand these and every Python concept that follows will make sense.
- Variables in Python are created by assignment — no type declaration needed, and the type can change dynamically
- The four core scalar types are int (whole numbers), float (decimals), str (text), and bool (True/False)
- Type conversion functions — int(), float(), str(), bool() — let you convert between types explicitly
- Arithmetic operators (+, -, *, /, //, %, **) perform math; comparison operators (==, !=, <, >, <=, >=) return True or False
- Logical operators (and, or, not) combine boolean expressions — the foundation of all conditional logic
Python Variables: Assignment, Naming Rules and Dynamic Typing
In Python, a variable is a named container that holds a value. You create a variable simply by assigning a value to a name: age = 25, name = "Priya", is_enrolled = True. Python is dynamically typed — you don't declare the type explicitly; Python infers it from the value. You can even reassign the same variable to a completely different type: x = 10 (integer), then x = "hello" (string) on the next line. Python won't complain. Variable names must start with a letter or underscore, can contain letters, digits, and underscores, and are case-sensitive (age, Age, and AGE are three different variables). By convention, Python variable names use snake_case (student_name, course_fee, is_active) rather than camelCase. Python also supports multiple assignment: a, b, c = 1, 2, 3 assigns three values in one line, and a, b = b, a swaps two variables without a temporary third variable. Constants (values that should not change) are written in ALL_CAPS by convention: MAX_STUDENTS = 30, API_BASE_URL = "https://api.example.com". Understanding variable scoping — local (inside a function), global (module level), and the global keyword — is the first real gotcha that trips up beginners at technical tests at Infosys Pune (SEZ Unit, Hinjewadi 411057) and Wipro Pune (Hinjewadi Phase 1).

Python Data Types: int, float, str and bool Explained
Python has four core scalar (single-value) data types you'll use in virtually every program. int (integer) stores whole numbers of unlimited size: student_count = 450, year = 2026, temperature = -5. float (floating-point) stores decimal numbers: price = 12999.99, gpa = 8.75, pi = 3.14159. Note that floating-point arithmetic is not exact — 0.1 + 0.2 evaluates to 0.30000000000000004 in Python due to IEEE 754 binary representation. For financial calculations, always use the decimal module. str (string) stores text as a sequence of Unicode characters: course_name = "AI Powered Application Development", city = "Pune". Strings are immutable — you cannot change individual characters; you create a new string instead. bool (boolean) stores either True or False — always capitalised in Python. Booleans are actually a subclass of int in Python: True == 1 and False == 0, which means you can do arithmetic with them (sum([True, False, True, True]) == 3). Python also has two special values worth knowing: None (Python's null, representing absence of value) and complex (for complex numbers like 3 + 4j, used in signal processing and scientific computing). At TCS Hinjewadi (Phase 2, Pune) and Infosys Pune, screening tests for Python roles typically include a type-identification question and a type-conversion scenario within the first 10 problems.
| Data Type | Python Keyword | Example Values | Convert Function | Mutable? |
|---|---|---|---|---|
| Integer | int | 25, -10, 0, 1000000 | int() | Immutable |
| Float | float | 3.14, -0.5, 99.9, 1.0 | float() | Immutable |
| String | str | "Pune", "hello", "AI" | str() | Immutable |
| Boolean | bool | True, False | bool() | Immutable |
| None Type | NoneType | None | N/A | Immutable |
Python Operators: Arithmetic, Comparison and Logical
Python operators fall into three main categories. Arithmetic operators perform mathematical calculations: + (addition), - (subtraction), * (multiplication), / (division, always returns float), // (floor division, returns integer result), % (modulo, returns remainder), ** (exponentiation). The modulo operator % is especially useful: checking if a number is even (n % 2 == 0), cycling through a fixed number of options (index % total_items), and validating check digits. The exponentiation ** operator makes power calculations clean: 2**10 returns 1024, and fractional exponents work: 27**(1/3) returns 3.0 (cube root). Comparison operators return True or False: == (equal), != (not equal), < (less than), > (greater than), <= (less than or equal), >= (greater than or equal). The double equals == compares values; the single equals = assigns values — confusing them is the most common beginner bug. Python allows chaining comparisons: 0 < age < 120 evaluates both conditions together, equivalent to age > 0 and age < 120. Logical operators combine boolean expressions: and returns True only if both sides are True. or returns True if at least one side is True. not returns the opposite boolean value. Python evaluates and and or with short-circuit evaluation: in a and b, if a is False, b is never evaluated. In a or b, if a is True, b is never evaluated. This has performance implications in large programs and is also the mechanism behind common Python idioms like name = input_name or "Anonymous".

Type Conversion, String Methods and Getting Input from Users
Type conversion (also called type casting) converts a value from one type to another. Python provides explicit conversion functions: int() converts to integer — int("42") returns 42; int(3.9) returns 3, truncating not rounding. float() converts to float — float("3.14") returns 3.14; float(5) returns 5.0. str() converts any value to its string representation. bool() converts to boolean: False for 0, empty string, empty list, None, and any other "falsy" value; True for everything else. The input() function always returns a string — this is the most common source of type errors for beginners. If you ask the user for their age with age = input("Enter age: ") and then try age > 18, Python raises a TypeError because you're comparing a string to an integer. Always convert: age = int(input("Enter age: ")). String methods you'll use constantly: .upper(), .lower(), .strip() (remove whitespace), .split(delimiter) (split into a list), .join(list) (join a list into a string), .replace(old, new), .startswith(prefix), .endswith(suffix), and f-strings for formatted output: f"Hello {name}, you are {age} years old." F-strings (Python 3.6+) are the modern standard for string formatting — faster, more readable, and preferred over % formatting and .format() in all new code. Career context: according to AmbitionBox 2025–26, Python freshers with strong fundamentals earn ₹3.2–4.5 LPA at Infosys, TCS, Wipro, and Cognizant Pune. Those who additionally understand data structures and OOP typically negotiate ₹4.5–6.0 LPA. ABC Trainings' AI Powered Application Development workshop builds from these Python fundamentals through to Flask, Django, data analysis, and AI integration.
Maharashtra's CMYKPY (Chief Minister Yuva Karya Prashikshan Yojana) pays ₹6,000–10,000 per month while you complete approved industrial training. ABC Trainings' AI Powered Application Development workshop in Pune — covering Python from basics through to web and AI — aligns with PMKVY 4.0 standards. Apply for CMYKPY alongside your enrollment to receive a monthly stipend while you learn. Students from our Pune Wagholi, Hadapsar, and Sangli batches have successfully claimed this benefit in 2025–26.Get the IT Brochure + Fees + Batch Dates on WhatsApp
Free 1:1 counselling. Placement track record. CMYKPY/PMKVY eligibility check.
💬 Get Brochure on WhatsApp📞 Call 7039169629About the author: Amit Kulkarni. 8 yrs leading IT training at ABC Trainings, ex-Infosys.
Visit Our Centers
- Wagholi (Pune): 1st Floor, Laxmi Datta Arcade, Pune-Ahilyanagar Highway. Call 7039169629
- Hadapsar (Pune HQ): 1st Floor, Shree Tower, opp. Vaibhav Theater, Magarpatta. Call 7039169629
- Cidco (Chh. Sambhajinagar): Kalpana Plaza, opp. Eiffel Tower, N-1 Cidco. Call 7039169629
- Osmanpura (Chh. Sambhajinagar): S.S.C Board to Peer Bazar Road, near Jama Masjid. Call 7039169629
- Sangli: Shubham Emphoria, 1st Floor, Above US Polo Assn., Sangli-Miraj Rd, Vishrambag. Weekend batches available. Call 7039169629
FAQs
Does Python require you to declare variable types like Java or C++?
No — Python is dynamically typed. You create a variable by simply assigning a value: age = 25. Python infers the type (int in this case) automatically. You can reassign the same variable to a different type later in the program without any explicit declaration. This makes Python faster to write but requires care when passing variables between functions, since there is no compile-time type checking unless you add type hints and run mypy.
What is the difference between = and == in Python?
Single equals = is the assignment operator — it stores a value in a variable: x = 10 stores 10 in x. Double equals == is the comparison operator — it tests whether two values are equal and returns True or False: x == 10 returns True if x is currently 10. Confusing them (using = inside an if condition) is a syntax error in Python (unlike C/C++ where it is a common bug). Always use == for comparisons inside if statements and while conditions.
Why does 0.1 + 0.2 not equal exactly 0.3 in Python?
This is a floating-point precision issue inherent to how computers store decimal numbers in binary (IEEE 754 standard). 0.1 cannot be represented exactly in base-2 binary, so there is a tiny rounding error in the stored value. When you add two imprecise representations, the error accumulates. For scientific calculations where this rounding does not matter, just use round(0.1 + 0.2, 2) to get 0.3. For financial calculations where exactness is required, use Python's decimal module: from decimal import Decimal; Decimal("0.1") + Decimal("0.2") returns exactly Decimal("0.3").
What Python topics are tested in fresher IT interviews at Infosys and TCS Pune?
Infosys, TCS, Wipro, and Cognizant test Python fundamentals heavily in fresher written tests and interviews. Common question types: identify the data type of a given expression, predict the output of a short code snippet involving type conversion, find the bug in a string comparison (= vs ==), compute the result of a series of arithmetic expressions with operator precedence, and write a small program using input() with proper int() conversion. Dynamic typing questions — what type is x after a series of reassignments — are also popular in on-campus drives at Pune-area engineering colleges.



