Data types
What are data types?
Data, such as variables, is not always of the same type. For example, if you concatenate two variables of type text, the result is that the texts are joined together.
1a = "3"
2b = "5"
3print(a + b)
435On the other hand, if the variables are numbers, the result is the sum of the numbers.
1a = 3
2b = 5
3print(a + b)
48And if you try to perform an operation with two types that are not compatible, you will get an error.
1a = 3
2b = "5"
3print(a + b)
4
5Traceback (most recent call last):
6 File "<stdin>", line 1, in <module>
7TypeError: unsupported operand type(s) for +: 'int' and 'str'This is Python's way of displaying error messages, which you should get used to. You can see from the message what the error was and on which line it occurred. int means number (Integer) and str is the data type for text (String). The error in this case is incompatible operands (left and right side) for the plus operator.
Learn to hack — start here
Hundreds of interactive courses, virtual labs and CTF challenges in your browser. Start a free trial — no card required.