GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Modul 11 von 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.

Anleitung

Um im Kurs weiterzukommen, sende einen Versuch dieses Quiz ab. Du kannst ihn nach der letzten Frage absenden.

Zum gewählten Modul

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck