Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Numbers and strings | The basics
Learn Python from Scratch
course content

Contenido del 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

bookNumbers and strings

Python variables can store data of various allowed types. Some of the simplest data types are strings and integers (official names in Python are "str" and "int").

You can print the data type of a variable by using type() function (see example below):

1234
#Example of a string variable var = "42" print(var) print(type(var))
copy

In the example above Python will print "42" and will treat this variable as a string.

In the example below it will also print "42", but will treat the variable as integer. You can only apply arithmetic operations to Numeric types (integer or others), not strings.

1234
#Example of an integer variable var = 42 print(var) print(type(var))
copy

Tarea

Analyze the code snippet on the right and fix it so that the program executes.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 6
toggle bottom row

bookNumbers and strings

Python variables can store data of various allowed types. Some of the simplest data types are strings and integers (official names in Python are "str" and "int").

You can print the data type of a variable by using type() function (see example below):

1234
#Example of a string variable var = "42" print(var) print(type(var))
copy

In the example above Python will print "42" and will treat this variable as a string.

In the example below it will also print "42", but will treat the variable as integer. You can only apply arithmetic operations to Numeric types (integer or others), not strings.

1234
#Example of an integer variable var = 42 print(var) print(type(var))
copy

Tarea

Analyze the code snippet on the right and fix it so that the program executes.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 6
toggle bottom row

bookNumbers and strings

Python variables can store data of various allowed types. Some of the simplest data types are strings and integers (official names in Python are "str" and "int").

You can print the data type of a variable by using type() function (see example below):

1234
#Example of a string variable var = "42" print(var) print(type(var))
copy

In the example above Python will print "42" and will treat this variable as a string.

In the example below it will also print "42", but will treat the variable as integer. You can only apply arithmetic operations to Numeric types (integer or others), not strings.

1234
#Example of an integer variable var = 42 print(var) print(type(var))
copy

Tarea

Analyze the code snippet on the right and fix it so that the program executes.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Python variables can store data of various allowed types. Some of the simplest data types are strings and integers (official names in Python are "str" and "int").

You can print the data type of a variable by using type() function (see example below):

1234
#Example of a string variable var = "42" print(var) print(type(var))
copy

In the example above Python will print "42" and will treat this variable as a string.

In the example below it will also print "42", but will treat the variable as integer. You can only apply arithmetic operations to Numeric types (integer or others), not strings.

1234
#Example of an integer variable var = 42 print(var) print(type(var))
copy

Tarea

Analyze the code snippet on the right and fix it so that the program executes.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 1. Capítulo 6
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
some-alt