Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Storing text | Common data types
Learn Python from Scratch
course content

Conteúdo do Curso

Learn Python from Scratch

Learn Python from Scratch

1. The basics
2. Arithmetic operations
3. Common data types
4. Conditional statements
5. Other data types
6. Loops
7. Functions

Storing text

You've already met with strings in the very first exercises. String - is simply a text which can contain letters, symbols, numbers, and so on. The one requirement - is to put your text inside quotes 'text' or "text" or '''text'''. The number of quotes on the left side must be equal to the number of quotes on the right side.

To convert a variable into a string use the str function or place your text inside quotes. It's useful if you, for example, need to make Python understand that 3 is string, not number (by default, Python will assign 3 as int).

For example, let's create a string with only the number 23

123456789
# first way to create string string1 = '23' print(type(string1)) # second way to create string string2 = 23 print(type(string2)) # convert it into string type string2 = str(string2) print(type(string2))
copy

Tarefa

Given a math expression assigned to variables expr1 and expr2. Not changing expr1, convert expr2 by using quotes, and print its value.

Tarefa

Given a math expression assigned to variables expr1 and expr2. Not changing expr1, convert expr2 by using quotes, and print its value.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 3. Capítulo 4
toggle bottom row

Storing text

You've already met with strings in the very first exercises. String - is simply a text which can contain letters, symbols, numbers, and so on. The one requirement - is to put your text inside quotes 'text' or "text" or '''text'''. The number of quotes on the left side must be equal to the number of quotes on the right side.

To convert a variable into a string use the str function or place your text inside quotes. It's useful if you, for example, need to make Python understand that 3 is string, not number (by default, Python will assign 3 as int).

For example, let's create a string with only the number 23

123456789
# first way to create string string1 = '23' print(type(string1)) # second way to create string string2 = 23 print(type(string2)) # convert it into string type string2 = str(string2) print(type(string2))
copy

Tarefa

Given a math expression assigned to variables expr1 and expr2. Not changing expr1, convert expr2 by using quotes, and print its value.

Tarefa

Given a math expression assigned to variables expr1 and expr2. Not changing expr1, convert expr2 by using quotes, and print its value.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 3. Capítulo 4
toggle bottom row

Storing text

You've already met with strings in the very first exercises. String - is simply a text which can contain letters, symbols, numbers, and so on. The one requirement - is to put your text inside quotes 'text' or "text" or '''text'''. The number of quotes on the left side must be equal to the number of quotes on the right side.

To convert a variable into a string use the str function or place your text inside quotes. It's useful if you, for example, need to make Python understand that 3 is string, not number (by default, Python will assign 3 as int).

For example, let's create a string with only the number 23

123456789
# first way to create string string1 = '23' print(type(string1)) # second way to create string string2 = 23 print(type(string2)) # convert it into string type string2 = str(string2) print(type(string2))
copy

Tarefa

Given a math expression assigned to variables expr1 and expr2. Not changing expr1, convert expr2 by using quotes, and print its value.

Tarefa

Given a math expression assigned to variables expr1 and expr2. Not changing expr1, convert expr2 by using quotes, and print its value.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

You've already met with strings in the very first exercises. String - is simply a text which can contain letters, symbols, numbers, and so on. The one requirement - is to put your text inside quotes 'text' or "text" or '''text'''. The number of quotes on the left side must be equal to the number of quotes on the right side.

To convert a variable into a string use the str function or place your text inside quotes. It's useful if you, for example, need to make Python understand that 3 is string, not number (by default, Python will assign 3 as int).

For example, let's create a string with only the number 23

123456789
# first way to create string string1 = '23' print(type(string1)) # second way to create string string2 = 23 print(type(string2)) # convert it into string type string2 = str(string2) print(type(string2))
copy

Tarefa

Given a math expression assigned to variables expr1 and expr2. Not changing expr1, convert expr2 by using quotes, and print its value.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 3. Capítulo 4
Mude 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