Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære What is a String? | Strings
Python Data Types
course content

Kursusindhold

Python Data Types

Python Data Types

1. Numeric Types
2. Boolean Type
3. Strings

book
What is a String?

A string it is a sequence of characters, which can contain both numbers and letters. But, let's highlight, that this sequence of characters must be enclosed in quotation marks (either single or double).

Example of creating a string using single quotes:

python

Example of creating a string using double quotes:

python

It is important to know how to create multi-line strings. In these situations single and double quotes do not work. Here we need to use three quotes. Let's look at what this looks like in practice.

python

Python 3.6 has a way to format strings that allows us to use built-in expressions inside string constants. This approach is called f-strings

Let's look at the examples.

python
python
Opgave

Swipe to start coding

You have to fill in the blanks.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 1
toggle bottom row

book
What is a String?

A string it is a sequence of characters, which can contain both numbers and letters. But, let's highlight, that this sequence of characters must be enclosed in quotation marks (either single or double).

Example of creating a string using single quotes:

python

Example of creating a string using double quotes:

python

It is important to know how to create multi-line strings. In these situations single and double quotes do not work. Here we need to use three quotes. Let's look at what this looks like in practice.

python

Python 3.6 has a way to format strings that allows us to use built-in expressions inside string constants. This approach is called f-strings

Let's look at the examples.

python
python
Opgave

Swipe to start coding

You have to fill in the blanks.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 1
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt