Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Converting: str() | Reunindo todos os tópicos
Tipos de Dados em Python
course content

Conteúdo do Curso

Tipos de Dados em Python

Tipos de Dados em Python

1. Conhecendo os números em Python
2. Verdadeiro ou falso?
3. Strings
4. Reunindo todos os tópicos

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.

Tarefa
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.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 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.

Tarefa
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.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 5
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt