GoConqr has a new look! Let us know what you think.

Module 11 of 24 · Text

LAB

David Khieu

LAB

Estimated time

5-10 minutes

Level of difficulty

Easy

Objectives

  • becoming familiar with the print() function and its formatting capabilities
  • practicing coding strings
  • experimenting with Python code

Scenario

Write a one-line piece of code, using the print() function, as well as the newline and escape characters, to match the expected result outputted on three lines. 

swiftCopy code

print("I'm\n\"learning\"\n\"\"\"Python\"\"\"")

Output:

rustCopy code

I'm "learning" """Python"""

Explanation:

  • The newline character \n is used to break the output into three lines.
  • Double quotes " are used to enclose the strings "learning" and "Python". To include double quotes within a string, we need to escape them with a backslash \ to avoid interpreting them as the end of the string.
  • The single quote in "I'm" is not escaped because we used double quotes to enclose the entire string.

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?