Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Converting: str() | Поєднання всіх тем разом
Типи даних у Python
course content

Зміст курсу

Типи даних у Python

Типи даних у Python

1. Знайомство з числами в Python
2. Істина чи брехня?
3. Рядки
4. Поєднання всіх тем разом

book
Converting: str()

Let's talk about strings!

As you remember, the following text leads to an error:

1
print("My age is" + 20)
copy

To implement concatenation here, we can just put 20 in quotes, like "20", but this solution doesn't look beautiful program-wise.

Hence, your work will be more fruitful if we can convert everything into strings. Here, the str() function should be implemented:

1
print("My age is " + str(20))
copy

Note

The syntax of this operation may appear familiar, resembling that of the int() or float() functions. In reality, it is identical, as it involves converting an argument into a string using the str() function.

Завдання
test

Swipe to begin your solution

You've already made it through a lot of chapters, way to go!

Your task here is to correct mistakes to make the program execute. Convert numbers to the str data type to manage the task.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 5
toggle bottom row

book
Converting: str()

Let's talk about strings!

As you remember, the following text leads to an error:

1
print("My age is" + 20)
copy

To implement concatenation here, we can just put 20 in quotes, like "20", but this solution doesn't look beautiful program-wise.

Hence, your work will be more fruitful if we can convert everything into strings. Here, the str() function should be implemented:

1
print("My age is " + str(20))
copy

Note

The syntax of this operation may appear familiar, resembling that of the int() or float() functions. In reality, it is identical, as it involves converting an argument into a string using the str() function.

Завдання
test

Swipe to begin your solution

You've already made it through a lot of chapters, way to go!

Your task here is to correct mistakes to make the program execute. Convert numbers to the str data type to manage the task.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 5
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt