Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Print Your String | Рядки
Типи даних у Python

Свайпніть щоб показати меню

book
Print Your String

What Are Strings in Python?

In Python, a string is a type of data used to store text. This can be anything like a company name, a currency symbol, an invoice note, or a financial report.

To create a string, you just put the text inside quotes. You can use either single quotes '...' or double quotes "..." — both work the same.

12345
category = "Office Rent" amount = "12000 USD" print("Expense Category:", category) print("Amount:", amount)
copy

Double Quotes Help with Apostrophes

If your text includes an apostrophe ', use double quotes to avoid errors:

12
note = "Payment for accountant's services (February)" print(note)
copy

Multi-line Strings

Sometimes you need to write text on multiple lines — like a short report or a transaction description. In that case, use triple quotes: '''...''' or """...""".

1234567891011
report = """ March Expense Report: - Office Rent: 12000 USD - Salaries: 45000 USD - Internet & Phone: 800 USD Total Expenses: 57800 USD """ print(report)
copy

If you try to do this with normal quotes, Python will give an error:

123
# This will cause an error: description = 'Transaction: Hosting payment for the accounting system.'
copy

Python doesn't allow line breaks inside single-line strings.

Завдання

Swipe to start coding

Imagine you're tracking the financial state of a company.

  1. If your company's financial report this month is bad, assign "loss" to the variable financial_result; otherwise, assign "profit".

  2. If your mood as an accountant is not great, assign "could be better" to the variable accountant_mood; otherwise, assign "could not be better".

  3. Does your mood depend on the company's finances? If yes — assign "yes" to the variable mood_depends_on_finance; otherwise — assign "no".

Рішення

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

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

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

Секція 3. Розділ 1
Ми дуже хвилюємося, що щось пішло не так. Що трапилося?

Запитати АІ

expand
ChatGPT

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

book
Print Your String

What Are Strings in Python?

In Python, a string is a type of data used to store text. This can be anything like a company name, a currency symbol, an invoice note, or a financial report.

To create a string, you just put the text inside quotes. You can use either single quotes '...' or double quotes "..." — both work the same.

12345
category = "Office Rent" amount = "12000 USD" print("Expense Category:", category) print("Amount:", amount)
copy

Double Quotes Help with Apostrophes

If your text includes an apostrophe ', use double quotes to avoid errors:

12
note = "Payment for accountant's services (February)" print(note)
copy

Multi-line Strings

Sometimes you need to write text on multiple lines — like a short report or a transaction description. In that case, use triple quotes: '''...''' or """...""".

1234567891011
report = """ March Expense Report: - Office Rent: 12000 USD - Salaries: 45000 USD - Internet & Phone: 800 USD Total Expenses: 57800 USD """ print(report)
copy

If you try to do this with normal quotes, Python will give an error:

123
# This will cause an error: description = 'Transaction: Hosting payment for the accounting system.'
copy

Python doesn't allow line breaks inside single-line strings.

Завдання

Swipe to start coding

Imagine you're tracking the financial state of a company.

  1. If your company's financial report this month is bad, assign "loss" to the variable financial_result; otherwise, assign "profit".

  2. If your mood as an accountant is not great, assign "could be better" to the variable accountant_mood; otherwise, assign "could not be better".

  3. Does your mood depend on the company's finances? If yes — assign "yes" to the variable mood_depends_on_finance; otherwise — assign "no".

Рішення

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

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

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

Секція 3. Розділ 1
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Ми дуже хвилюємося, що щось пішло не так. Що трапилося?
some-alt