Course Content
Python Data Types
Python Data Types
Numeric Types
Let's start our acquaintance with the simplest and most popular data type - numeral. But what is it? A numeric data type is a data type that stores numbers. It is worth noting that this data type is immutable - that is, if we have already defined a variable as a number, we will no longer be able to change this variable unless we redefine it.
There are three numeric types in Python:
- integers,
- floating point numbers,
- and of course the complex numbers.
How exactly can we create a variable of a numeric type? Let's take a look at the example.
As we can see from the examples, creating a variable of a numeric type is very simple, be it an integer or a complex one, we just need to assign a value to the variable.
In the example, we can see an unusual moment for us, namely
print(f'This is an integer = {a}')
.These are the so-called f-strings. f-strings allow us to print strings with variables in a single pair of quotes. Let's look at the syntax. All text we want to print must be enclosed in quotation marks preceded by an f, and any variables we want to print within that text must be enclosed in curly braces.
And now let's have a practice.
Swipe to show code editor
- You need to create the following numeric types as
integer, floating point number, complex number
- Please, use the following numbers for it:
integer : 784
floating point number: 658.34
complex number: 65+7j
Thanks for your feedback!
Numeric Types
Let's start our acquaintance with the simplest and most popular data type - numeral. But what is it? A numeric data type is a data type that stores numbers. It is worth noting that this data type is immutable - that is, if we have already defined a variable as a number, we will no longer be able to change this variable unless we redefine it.
There are three numeric types in Python:
- integers,
- floating point numbers,
- and of course the complex numbers.
How exactly can we create a variable of a numeric type? Let's take a look at the example.
As we can see from the examples, creating a variable of a numeric type is very simple, be it an integer or a complex one, we just need to assign a value to the variable.
In the example, we can see an unusual moment for us, namely
print(f'This is an integer = {a}')
.These are the so-called f-strings. f-strings allow us to print strings with variables in a single pair of quotes. Let's look at the syntax. All text we want to print must be enclosed in quotation marks preceded by an f, and any variables we want to print within that text must be enclosed in curly braces.
And now let's have a practice.
Swipe to show code editor
- You need to create the following numeric types as
integer, floating point number, complex number
- Please, use the following numbers for it:
integer : 784
floating point number: 658.34
complex number: 65+7j
Thanks for your feedback!
Numeric Types
Let's start our acquaintance with the simplest and most popular data type - numeral. But what is it? A numeric data type is a data type that stores numbers. It is worth noting that this data type is immutable - that is, if we have already defined a variable as a number, we will no longer be able to change this variable unless we redefine it.
There are three numeric types in Python:
- integers,
- floating point numbers,
- and of course the complex numbers.
How exactly can we create a variable of a numeric type? Let's take a look at the example.
As we can see from the examples, creating a variable of a numeric type is very simple, be it an integer or a complex one, we just need to assign a value to the variable.
In the example, we can see an unusual moment for us, namely
print(f'This is an integer = {a}')
.These are the so-called f-strings. f-strings allow us to print strings with variables in a single pair of quotes. Let's look at the syntax. All text we want to print must be enclosed in quotation marks preceded by an f, and any variables we want to print within that text must be enclosed in curly braces.
And now let's have a practice.
Swipe to show code editor
- You need to create the following numeric types as
integer, floating point number, complex number
- Please, use the following numbers for it:
integer : 784
floating point number: 658.34
complex number: 65+7j
Thanks for your feedback!
Let's start our acquaintance with the simplest and most popular data type - numeral. But what is it? A numeric data type is a data type that stores numbers. It is worth noting that this data type is immutable - that is, if we have already defined a variable as a number, we will no longer be able to change this variable unless we redefine it.
There are three numeric types in Python:
- integers,
- floating point numbers,
- and of course the complex numbers.
How exactly can we create a variable of a numeric type? Let's take a look at the example.
As we can see from the examples, creating a variable of a numeric type is very simple, be it an integer or a complex one, we just need to assign a value to the variable.
In the example, we can see an unusual moment for us, namely
print(f'This is an integer = {a}')
.These are the so-called f-strings. f-strings allow us to print strings with variables in a single pair of quotes. Let's look at the syntax. All text we want to print must be enclosed in quotation marks preceded by an f, and any variables we want to print within that text must be enclosed in curly braces.
And now let's have a practice.
Swipe to show code editor
- You need to create the following numeric types as
integer, floating point number, complex number
- Please, use the following numbers for it:
integer : 784
floating point number: 658.34
complex number: 65+7j