YouTube Excerpt: #python #stringspython #asciicode #stringcomparison Exercises: Compare the following strings in two ways - with the len() function and without using the len() function: 1. x = 'triceratops' y = 'spinosaurus' 2. x = 'relativism' y = 'availability' 3. hd1 = 'All the king's horses and all the king's men couldn't put Humpty together again!' hd2 = 'All the king's horses and all the king's men couldn't put humpty together again!' ______________________________________________________________________________________ Summary of the video First example: x = 'cupboard' y = 'lamp' First of all compared these strings using the len() function and if sentence. But after that we compared them without using the len() function and got an opposite result. In order to explain it we need to know what is ASCII code. Let's take a look at ASCII conversion table. Second example: m = 'chair' n = 'table' Although these two strings contain the same of characters, in the comparison without len() the string 'table' is greater than 'chair', because the ASCII code of the letter t is greater than the ASCII code from the letter c. ASCII codes from uppercase letters are less than ASCII codes from lowercase letters. How Python compares strings without the len() function? It compares ASCII codes from each character going character for character. If the codes from the first character of each strings are different Python immediately gives the result of comparison and doesn't move to the next character. Third example: m = 'chair' n = 'Table' Fourth example: m = 'chair' z = 'cHair' Fifth example: g1 = 'How are you friend?' g2 = 'How are you Friend?' Python course #2 in English 11 Python programming language course in English #pythonexercises #pythontasks #python程式設計語言 #python程式設 #程式設計語言 #程式設
#python #stringspython #asciicode #stringcomparison Exercises: Compare the following strings in two ways - with the len() function and without...
Curious about String Comparison In Python; Examples + Exercises's Color? Explore detailed estimates, income sources, and financial insights that reveal the full picture of their profile.
color style guide
Source ID: JjaDTRc6OJE
Category: color style guide
View Color Profile 🔓
Disclaimer: %niche_term% estimates are based on publicly available data, media reports, and financial analysis. Actual numbers may vary.
Sponsored
Sponsored
Sponsored