Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Numeric Types | Numeric Types
Python Data Types
course content

Course Content

Python Data Types

Python Data Types

1. Numeric Types
2. Boolean Type
3. Strings

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.

Task

  • 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

Task

  • 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

Everything was clear?

Section 1. Chapter 1
toggle bottom row

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.

Task

  • 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

Task

  • 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

Everything was clear?

Section 1. Chapter 1
toggle bottom row

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.

Task

  • 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

Task

  • 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

Everything was clear?

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.

Task

  • 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

Section 1. Chapter 1
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt