DEV Community

Onaolapo-11
Onaolapo-11

Posted on

Comparison of strings is lexicographically-sensitive

Day 78 [December 2nd, 2025 started reading around 12am]

I need to buckle down, as I'm still lagging on day day 3 & 4 goals, "Day 3-4: Control structures (if-else, loops)", as well as day 5 (and 6) goals, "Day 5-6: Functions and modules", and Day 7 target (exercises) (Meta AI, personal communication, August 8, 2025). If I haven't covered this, I can't make progress on day 8 - 77 goals.

Goals:
As extracted from the 'Python for Software Development' textbook by Halvorsen (n.d.):

  • Plotting in Python ✅
  • Subplots✅
  • Exercises✅
  • If ... Else
  • Arrays
  • For Loops
  • Nested
  • For Loops
  • While Loops
  • Exercises
  • Creating Functions in Python - Introduction
  • Functions with multiple return values
  • Exercises
  • Creating Classes in Python
  • The init () Function
  • Exercises
  • Creating Python Modules
  • Exercises

Notes:
Python for Data Science, AI & Development Course (IBM) (Santarcangelo, n.d.):
Module 2: Python Programming Fundamentals

Conditions and Branching

  • The block of code under if statement only run when the if condition is True
  • Comparison of strings is lexicographically-sensitive (comparison is done one a character by character basis dependent on how the characters are ordered in Unicode or ASCII) (see also Google, 2025a; Google, 2025b). That's why "10"<"7" evaluates to True (the first characters are compared).

Summary:
Comparison of strings is lexicographically-sensitive.

References:

  1. Google. (2025a). Google Search with AI. [Large language model]. https://www.google.com/search?q=in+python+is+%2210%22+less+than+%227%22%3F&oq=in+python+is+%2210%22+less+than+%227%22%3F&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRigATIHCAIQIRigATIHCAMQIRigATIHCAQQIRigATIHCAUQIRiPAjIHCAYQIRiPAjIHCAcQIRiPAtIBCTEyMzYwajBqOagCBrACAfEFn-fcgSi5fxs&sourceid=chrome&ie=UTF-8

  2. Google. (2025b). Google Search with AI. [Large language model]. https://www.google.com/search?q=Comparison+of+strings+is+lexicographically-sensitive&oq=Comparison+of+strings+is+lexicographically-sensitive&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIKCAEQABiABBiiBDIHCAIQABjvBTIKCAMQABiABBiiBNIBBzQ3NmowajmoAgawAgHxBWWZfDjzK9C2&sourceid=chrome&ie=UTF-8

  3. Halvorsen, H. (n.d.). Python. https://halvorsen.blog/documents/programming/python/python.php#python4

  4. Santarcangelo, J. (n.d.). Python for data science, AI & development [MOOC]. Coursera. https://coursera.org/learn/python-for-applied-data-science-ai

Top comments (0)