Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте What is a String? | Strings
Python Data Types

bookWhat 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:

Input:
string = 'Python'
print('One of the most popular programming language is:', string)

Output:
One of the most popular programming language is: Python

Example of creating a string using double quotes:

Input:
string = "Python"
print('One of the most popular programming language is:', string)

Output:
One of the most popular programming language is: 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.

Input:
string = '''Roses are red 
Violets are blue 
Cats can learn Python
What about you?'''
print(string)

Output:
Roses are red
Violets are blue
Cats can learn Python
What about you?

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.

Input:
string = 'world'
print(f'Hello, {string}')

Output:
Hello, world
Input:
a = 5
b = 13
print(f'{a} + {b} = {a+b}')

Output:
5 + 13 = 18
Завдання

Swipe to start coding

You have to fill in the blanks.

Рішення

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

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

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

Секція 3. Розділ 1
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

close

Awesome!

Completion rate improved to 3.85

bookWhat 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:

Input:
string = 'Python'
print('One of the most popular programming language is:', string)

Output:
One of the most popular programming language is: Python

Example of creating a string using double quotes:

Input:
string = "Python"
print('One of the most popular programming language is:', string)

Output:
One of the most popular programming language is: 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.

Input:
string = '''Roses are red 
Violets are blue 
Cats can learn Python
What about you?'''
print(string)

Output:
Roses are red
Violets are blue
Cats can learn Python
What about you?

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.

Input:
string = 'world'
print(f'Hello, {string}')

Output:
Hello, world
Input:
a = 5
b = 13
print(f'{a} + {b} = {a+b}')

Output:
5 + 13 = 18
Завдання

Swipe to start coding

You have to fill in the blanks.

Рішення

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

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

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

Секція 3. Розділ 1
single

single

close

Awesome!

Completion rate improved to 3.85

bookWhat 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:

Input:
string = 'Python'
print('One of the most popular programming language is:', string)

Output:
One of the most popular programming language is: Python

Example of creating a string using double quotes:

Input:
string = "Python"
print('One of the most popular programming language is:', string)

Output:
One of the most popular programming language is: 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.

Input:
string = '''Roses are red 
Violets are blue 
Cats can learn Python
What about you?'''
print(string)

Output:
Roses are red
Violets are blue
Cats can learn Python
What about you?

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.

Input:
string = 'world'
print(f'Hello, {string}')

Output:
Hello, world
Input:
a = 5
b = 13
print(f'{a} + {b} = {a+b}')

Output:
5 + 13 = 18
Завдання

Swipe to start coding

You have to fill in the blanks.

Рішення

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

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

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

some-alt