An integer (int) is a whole number — positive, negative, or zero — with no decimal point. Python integers have no fixed size limit, unlike many other languages.
students = 45
batches = -2 # negative integers are valid
big_number = 123456789012345
print(students, batches, big_number)
print(type(students))A float represents a number with a decimal point, used for prices, percentages, measurements, and any value requiring precision.
course_fee = 15000.50
gst_rate = 0.18
pi_value = 3.14159
print(course_fee, gst_rate, pi_value)
print(type(course_fee))Python also supports complex numbers, written as a + bj, where 'j' represents the imaginary part. These are rarely used in business analytics but are common in scientific and engineering computing.
z = 3 + 4j
print(z)
print(z.real) # real part
print(z.imag) # imaginary part
print(type(z))You can convert freely between int, float, and complex using built-in functions.
| Function | Converts To | Example |
|---|---|---|
| int(x) | Integer | int(9.8) → 9 |
| float(x) | Float | float(10) → 10.0 |
| complex(x) | Complex | complex(5) → (5+0j) |
Python has several built-in functions for common numeric operations — no import needed.
| Function | Purpose | Example |
|---|---|---|
| abs(x) | Absolute (positive) value | abs(-15) → 15 |
| round(x, n) | Rounds to n decimal places | round(9.876, 2) → 9.88 |
| pow(x, y) | x raised to power y | pow(2, 5) → 32 |
| max(a,b,...) | Largest value | max(4, 9, 2) → 9 |
| min(a,b,...) | Smallest value | min(4, 9, 2) → 2 |
| sum(list) | Total of a list of numbers | sum([10,20,30]) → 60 |
marks = [78, 85, 92, 66, 88]
print("Highest:", max(marks))
print("Lowest:", min(marks))
print("Total:", sum(marks))
print("Average:", round(sum(marks)/len(marks), 2))For advanced mathematical operations (square roots, logarithms, trigonometry), Python provides the built-in math module, which must be imported first.
import math
print(math.sqrt(64)) # square root
print(math.ceil(4.2)) # round UP
print(math.floor(4.8)) # round DOWN
print(math.factorial(5)) # 5! = 120
print(math.pi) # value of piBasic (5 Questions)
1. Store your age as an integer and your height (in meters) as a float, then print both.
2. Use abs() to print the absolute value of -45.
3. Round the number 7.6789 to 2 decimal places.
4. Find the maximum and minimum of 5 numbers using max() and min().
5. Import the math module and print the value of pi.
Intermediate (5 Questions)
1. Calculate the average of 6 student marks stored in a list using sum() and len().
2. Use math.sqrt() to find the square root of a number entered by the user.
3. Compare math.ceil() and math.floor() on the number 6.3 and explain the difference.
4. Write a program to calculate compound interest using pow().
5. Create a program that converts a float course fee into an integer and explains what is lost.
Advanced (5 Questions)
1. Build a 'Marks Analyzer': given a list of marks, print the highest, lowest, total, and average.
2. Write a program to calculate the EMI-style monthly payment using basic math functions.
3. Explain why 0.1 + 0.2 does not exactly equal 0.3 in Python, with a code demonstration.
4. Use math.factorial() to calculate the number of ways to arrange 6 students in a row.
5. Create a GST Calculator that takes a price, applies 18% GST, and rounds the final amount to 2 decimals.
Q1. Which data type represents whole numbers?
Q2. What does round(9.876, 2) return?
Q3. Which module must be imported to use sqrt()?
Q4. What does math.ceil(4.2) return?
Q5. What is the result of pow(2, 3)?
Assignment: Course Fee & GST Calculator
Expected Output: A script that correctly computes GST-inclusive course fees and displays a clean, rounded final amount — usable as a real billing helper for the institute.
Use this space to write down key points, doubts, and your own examples from today's session.