Starting with 0.4 − 0.3: Python Basics and a Study Strategy Reset

Reviewing Python operators, conditionals, and floating-point approximation in the library, then clarifying the roles of my university text, Understanding Analysis, Python, and English.

阅读中文版 →

I spent a little time in the library this morning and returned in the evening. The main task was to continue with basic Python syntax. I also reorganised the roles of mathematics, programming, and English in my study plan.

One very practical problem kept getting in the way: I forgot to save what I had written. While coding, I also kept forgetting to switch between Chinese and English input. These are not difficult concepts, but they interrupt the exercise whenever the wrong characters or punctuation appear.

A tablet, headphones, and a laptop running a Python lesson and code on a library desk
Today's setup: a short visit in the morning, then another Python session in the library at night.

Describing the operators precisely

The operators I met today are brief on the page, but their meanings need more care than their informal Chinese names suggest.

  • / performs regular division. In Python 3, the result is represented as a float: 7 / 2 gives 3.5, while 4 / 2 gives 2.0.
  • // performs floor division. 7 // 2 gives 3, but -7 // 2 gives -4, because the quotient is rounded down toward negative infinity rather than simply truncated.
  • % is the modulo operator. For example, 7 % 2 gives 1. It is related to floor division by a == (a // b) * b + a % b.
  • ** is exponentiation: 2 ** 3 gives 8.
  • += and -= are augmented assignments. x += 1 updates x with the result of x + 1; x -= 1 works similarly.

At this point, I am still identifying the basic behaviour. I need to try positive values, negative values, and decimals, especially when combining // and %.

The colon after if and else

Another detail kept returning today: both the if line and the else line end with a colon. The indented lines below them form their code blocks.

score = 700

if score >= 680:
    print('Congratulations on entering university')
else:
    print('The exam is over')

The colon introduces a block, and indentation shows which statements belong to that branch. Remembering the condition while forgetting the colon or indentation is still enough to stop the program from working as intended.

Python comparison expressions and an if-else exercise on a computer screen
Practising comparisons and conditionals while continuing to check the syntax line by line.

Why 0.4 0.3 may not display as exactly 0.1

I noticed that after entering 0.4 and 0.3, Python printed their difference as 0.10000000000000003.

It is too broad to say that a computer uses binary and therefore always loses information. More precisely, many finite decimal fractions do not have a finite binary representation. A Python float stores a nearby binary approximation, and an operation can make that tiny approximation error visible.

x = 0.4
y = 0.3

print(x + y)  # 0.7
print(x - y)  # 0.10000000000000003

For comparisons where “close enough” is appropriate, Python provides math.isclose(). Situations such as money, where exact decimal representation matters, are a reason to learn about decimal.Decimal. For now, I have identified the source of the output; I have not mastered floating-point arithmetic.

A Python terminal showing that zero point four minus zero point three prints as zero point one followed by additional digits
The output of 0.4 0.3 makes the floating-point approximation visible.

Clarifying the main line of study

I also adjusted my study strategy today. My university text should be the main line: follow the definitions, theorems, examples, and assignments in the course, and build the foundation of the degree first.

Abbott's Understanding Analysis will serve as a second pass. It is not replacing the university text, nor is it a book I need to race through. Its role is to train my attention on rigorous definitions, why a theorem is true, and how a proof is written. Returning to the corresponding section when the university course reaches a related topic should make that role clearer.

Python and English remain in the plan. Python lets me practise expressing calculations and processes; English belongs inside the concrete setting of textbooks, terminology, and source reading. This gives me one course-centred main line, supported by analysis, programming, and English, rather than four equally heavy tracks competing at once.

A phone screen recording a study strategy centred on the university mathematics text, with Understanding Analysis as a supplement
The revised order: the university text first, Understanding Analysis as a supplement, with Python and English continuing alongside them.

Before the next coding session, I need to check the input method and save the file before running it. At the end, I can record three short points: what I tried, what remains uncertain, and where to resume. That is more concrete than becoming annoyed only after unsaved work disappears.

Enough for today.

Comments

0 comments