Задача

1/13

Strings. Review. String comparison

Теория

Lines. Overview

A string - is a list (or sequence) of characters located in a particular okay. The whole sequence of characters is treated as a single object.

A character is anything you can type on the keyboard with a single keystroke (letter, number, backslash, or some other character).

Strings can have spaces: "Hello world!".

An empty string is a string that has 0 characters.

Python accepts as strings anything enclosed in quotes (" ") or apostrophes (' ').

In Python, a string is of type str.
 
Need to remember!
Strings in Python are immutable!


You can write a new value to a string using the input statement
s = input()

You can also simply assign a string value to the variable, such as  
s = 'Python'
or so
s = "Python"

You can determine the length of a string using the built-in function len()
n = len(s)


String comparison

Strings can be compared to each other just like numbers. You can determine which of the lines is greater, which is less.

When comparing strings, character codes are compared. There are dozens, if not hundreds, of character encodings. The easiest way to understand this concept is to understand one of the simplest, ASCII (read here).  ;

It is necessary to understand that in modern encodings both Russian and English letters are arranged in alphabetical order, the numbers also go from smaller to larger. 
For example, in the ASCII code table, the code for the English letter 'A' - 65, letters 'a' - 97, digit '0' has code 48. Russian letters are located in the extended part of the ASCII code table (numbers from 128 to 255). Capital letters come before (i.e. have a smaller code) than lowercase letters.

In most of the encoding tables used, the patterns are the same, lowercase letters are later than uppercase letters, numbers are earlier than letters, and Russian letters are later than English ones.
 
When comparing characters or strings, Python converts the characters to their respective ordinal values ​​and then compares from left to right. 

For example: "locomotive"  < "steamboat", because the words differ in the fifth letter and "in" < "x".

Задача

Compare pairs of words, indicate the sign in your answer: >, <, =

"steam" and "park"

Выберите правильный ответ, либо введите его в поле ввода

Комментарий учителя