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.
12345category = "Office Rent" amount = "12000 USD" print("Expense Category:", category) print("Amount:", amount)
Double Quotes Help with Apostrophes
If your text includes an apostrophe '
, use double quotes to avoid errors:
12note = "Payment for accountant's services (February)" print(note)
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 """..."""
.
1234567891011report = """ March Expense Report: - Office Rent: 12000 USD - Salaries: 45000 USD - Internet & Phone: 800 USD Total Expenses: 57800 USD """ print(report)
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.'
Python doesn't allow line breaks inside single-line strings.
Swipe to start coding
You're practicing how to assign and print string values. Complete the following:
- Assign either
"loss"
or"profit"
to the variablefinancial_result
. - Assign either
"could be better"
or"could not be better"
to the variableaccountant_mood
. - Assign either
"yes"
or"no"
to the variablemood_depends_on_finance
.
Use your own choices β there is no condition or logic to calculate here. Just practice assigning strings and printing them.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 3.03
Print Your String
Swipe to show menu
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.
12345category = "Office Rent" amount = "12000 USD" print("Expense Category:", category) print("Amount:", amount)
Double Quotes Help with Apostrophes
If your text includes an apostrophe '
, use double quotes to avoid errors:
12note = "Payment for accountant's services (February)" print(note)
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 """..."""
.
1234567891011report = """ March Expense Report: - Office Rent: 12000 USD - Salaries: 45000 USD - Internet & Phone: 800 USD Total Expenses: 57800 USD """ print(report)
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.'
Python doesn't allow line breaks inside single-line strings.
Swipe to start coding
You're practicing how to assign and print string values. Complete the following:
- Assign either
"loss"
or"profit"
to the variablefinancial_result
. - Assign either
"could be better"
or"could not be better"
to the variableaccountant_mood
. - Assign either
"yes"
or"no"
to the variablemood_depends_on_finance
.
Use your own choices β there is no condition or logic to calculate here. Just practice assigning strings and printing them.
Solution
Thanks for your feedback!
Awesome!
Completion rate improved to 3.03single