The cursor blinked quietly on the screen.
_
Pran stretched his fingers and leaned closer to the keyboard.
The robot was still standing on the screen.
[^_^]
/| |\
/ \
A system message appeared underneath it.
PYTHON MODULE PROGRESS: 20%
NEXT MODULE: CALCULATION ENGINE
Pran smiled.
"Finally… some math."
The computer screen flickered.
Then a new message appeared.
NUMBERS ARE USED IN MANY PROGRAMS
ACTIVATE CALCULATION ENGINE
Pran had already seen numbers before while learning C.
But Python worked a little differently.
The computer displayed a simple example.
a = 5
b = 3
print(a + b)
Pran looked at the code.
"No special types… no int keyword…"
That was one thing that made Python easier.
In Python, you don't need to declare the type of a variable.
You can simply write:
a = 5
Python automatically understands that 5 is a number.
Pran ran the program.
The screen printed:
8
The robot nodded.
The computer displayed another message.
ADDITION VERIFIED
Pran leaned back.
"Okay, that was easy."
But programming isn't just about addition.
Computers perform many types of calculations.
The system showed more examples.
Subtraction
a = 10
b = 4
print(a - b)
Output:
6 Multiplication
a = 6
b = 3
print(a * b)
Output:
18 Division
a = 10
b = 2
print(a / b)
Output:
5.0
Pran noticed something.
"Why is it 5.0 instead of 5?"
The robot displayed another explanation.
DIVISION IN PYTHON RETURNS DECIMAL RESULTS
Numbers like 5.0 are called floating point numbers, or floats.
They represent numbers with decimals.
Example:
3.5
8.2
10.75
These are useful for things like:
measurements
scientific calculations
physics simulations
financial data
The screen flickered again.
Another message appeared.
CALCULATION TEST REQUIRED
Then the system displayed a challenge.
ADD TWO NUMBERS ENTERED BY THE USER
Pran raised an eyebrow.
"That sounds interesting."
The computer showed another piece of code.
num1 = input("Enter first number: ")
num2 = input("Enter second number: ")
result = num1 + num2
print("Result:", result)
Pran typed it and ran the program.
The screen asked:
Enter first number:
He typed:
5
Then:
Enter second number:
He typed:
3
The output appeared.
Result: 53
Pran blinked.
"Wait… that's wrong."
The robot looked confused too.
The system displayed a message.
INPUT RETURNS TEXT BY DEFAULT
That meant the numbers were being treated as text, not actual numbers.
So Python was combining the text.
"5" + "3" → "53"
Pran nodded slowly.
"So we need to convert the text into numbers."
Exactly.
Python uses the function int() to convert text into integers.
The corrected program looked like this.
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
result = num1 + num2
print("Result:", result)
Pran ran the program again.
Enter first number:
He typed:
5
Next:
Enter second number:
He typed:
3
The output appeared.
Result: 8
Pran smiled.
"Now that works."
The robot moved slightly.
[^o^]
/| |\
/ \
Another system message appeared.
CALCULATION ENGINE ACTIVATED
Then another message.
PYTHON MODULE PROGRESS: 30%
Pran crossed his arms.
"Thirty percent already."
The computer displayed another system message.
NEXT MODULE: DECISION SYSTEM
Pran smiled again.
"That sounds familiar."
He had already learned how computers make decisions using if statements.
But Python had a simpler way of writing them.
The cursor blinked again.
_
Waiting.
Ready for the next command.
Pran placed his fingers on the keyboard.
"Alright," he said quietly.
"Let's see how Python makes decisions."
Next chapter:
Chapter 14 — Making Decisions
You will learn:
if
else
comparisons
decision-based programs
