Python: Define a string containing special characters in various forms
Python Basic: Exercise-92 with Solution
Write a Python program to define a string containing special characters in various forms.
Sample Solution:
Python Code :
# Print a string containing special characters without escaping.
print()
print("\#{'}${\"}@/")
# Print a string containing special characters with escaped single quotes.
print("\#{'}${\"}@/")
# Print a raw string using triple-quotes with special characters.
print(r"""\#{'}${"}@/""")
# Print a string containing special characters without escaping.
print('\#{\'}${"}@/')
# Print a string containing special characters with escaped single quotes.
print('\#{'"'"'}${"}@/')
# Print a raw string using triple-quotes with special characters.
print(r'''\#{'}${"}@/''')
print()
Sample Output:
\#{'}${"}@/ \#{'}${"}@/ \#{'}${"}@/ \#{'}${"}@/ \#{'}${"}@/ \#{'}${"}@/
Flowchart:
Python Code Editor:
Previous: Write a Python program to swap two variables.
Next: Write a Python program to get the identity of an object.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://198.211.115.131/python-exercises/python-basic-exercise-92.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics