Data Types
Welcome, aspirants, to a critical juncture in your programming journey. Today, we explore the fundamental concepts of Python — the basic data types.
˙⋆˖⁺‧₊☽◯☾₊‧⁺˖⋆˙
Int & Float Types
In programming, numbers are used to represent numerical values.
There are two basic types of number values:
int (integer) – whole numberfloat (floating-point) – numbers with decimal points
Arithmetic Operations (operators):
+ : Addition- : Subtraction* : Multiplication/ : Division
String Type
String Syntax
In Python, a string is a sequence of characters enclosed in single quotes (
In many other programming languages (e.g. C++, C#, Java), single quotes (
So it's recommended to keep the same in Python.
Difference: Numbers and Strings
- • Numbers are used for numerical calculations, while strings are used for representing text.
- • Arithmetic operations such as addition, subtraction, multiplication, and division can only be performed on numbers, not on strings.
print(6 + 4) # Output: 10 print("6 + 4") # Output: 6 + 4
- • Strings can be concatenated (joined together) using the
+ operator, but the result is a new string, not a numerical calculation.#Difference examples: print(10 + 7) # Number addition print("The " + "world!") # String concatenation
Practical Application
In the Hall of Elements, you must demonstrate your understanding of fundamental components: strings, integers, and floats.
Mage Age: 120
Power Level: 95.7
Remember: Strings are for names and text, integers for whole numbers, and floats for numbers with decimals.