Your train app shows route 07A. Why does the zero need to stay?
Your train app shows route zero seven A and a fare of seven euro. You can add another euro to the fare. But if the app drops the first zero from the route code, does it still show the same label?
You already know that a variable can store a number. Here, fare stores the integer seven, so you can use it in a calculation. The route prefix is a label. Store zero seven in quotes and Python keeps both digits as text.
Watch Python store zero five in prefix and the letter B in suffix. On the third line, plus puts the suffix straight after the prefix. When you print the result, you see zero five B. The first zero stays, and no space is added.
This time, both pieces look like numbers. The quotes tell you that both are text. If you print zero seven plus two, with each piece in quotes, what appears on the screen? Pick an answer.
That join is called concatenation. When you use plus between two strings in Python, the characters from the left string come first, then the characters from the right. The digits stay exactly as you wrote them.
Look at zero seven A. The zero is at index zero, the seven is at index one, and A is at index two. So when you write route with zero in square brackets, Python returns the string containing just the digit zero. Python has no separate character type.
Join zero seven and A to get the string zero seven A, and store it in route. Next, use index zero to read the first character and store it in first. That value is a one-character string. When you print it, you see just the digit zero.
Now the route code is made by joining zero four and B. The code then takes the character at index one. What value does that give you, and is it text or a number? Pick the option that gets both right.
Look at the left column. Plus joins the strings zero seven and two to give zero seven two. Predicting nine here treats the strings as numbers. Now look at the right column. Seven and two are integers, so plus adds them and gives nine.
Write the output of the following code. The list stores three route codes collected from the app. Sorting compares characters from left to right, so zero two B comes before zero seven A and twelve C. The last line prints the whole first code, with no quotes.