Values¶
You already known the concept of values in Basic Terms, now we are going to learn more about it and learn how to write it in a way that machine can understand.
Value Types¶
You cannot mention value without mentioning value types. Value types describes what category the value is.
Here are some common types:
- Number: Don’t need to explain this much.
- String: It’s definition is “a sequence of characters”, it’s text. it can be only one character, a word, a sentence, or even a book. (It can be blank too)
- Boolean: If a value’s type is Boolean, it can only be True or False.
How to Write a Value¶
- Number: Numbers don’t need to write in a special way, for example
1,1000,20.5are all correct - String: In order to present a string, you need to add quotation mark to it. For example you want to write a value test, you need to code
"test"."I love you","a","123",""(blank string) are all correct. - Boolean: Boolean type is either
TrueorFalse.
Difference between 5 and "5"¶
This is a question that a lot of students are confused about. 5 is a number, it can add with other numbers for example 5 + 1 will give you 6. "5" is a string, which is a text. You can’t add it to numbers, but you can add it to other strings, for example "5" + "test" will give you "5test", "5" + "1" will give you "51".
Last update:
March 24, 2021
Created: March 24, 2021
Created: March 24, 2021