카테고리 없음

Examining Strings Specifically in Python

AKA.DM 2024. 9. 23. 07:33
반응형

When we want to keep a data as a string, we must write it in quotation marks. Otherwise, we will get an error.

 

 

 

If we want to take notes with a expression in the code cell, we should use the hashtag(#) character. 

 

If a number is enclosed in quotes, its type is now a string. 

 

Strings an mathmatical operators can be used together. However, the mathematical operator is used to configure the string, not to perform arithmetic operations.

 

For example, the "+" sign is used below. This operation is used to concatenate two string expressions.

 

We can use the multipication operator on string values. However, this multipication operation is not an arithmetic operatioin, but causes a structural operation in strings.

For example, the string expression "hello" is multiplied by 3. As a result, it is not a mathematical operaiton, it caused the string expression to increase by the desired amout.

 

 

Two string expressions cannot be multiplied by each other. Otherwise you will get a type error.

 

 

You may not be able to use some mathematical operators on strings. For example, Python does not allow substraction and division on strings.

 

반응형