Menu
CoddyTech

Output, Strings, and Comments

Lesson 2 of 48 in Coddy's Python for C# Developers course.

Print exact text and distinguish string data from comments.

C# reference excerpt

Executable statements use C# top-level program style; type-only examples are declarations. System names assume the usual using System directive.

// A note, not output
Console.WriteLine("State: ready");
Console.WriteLine("Don't stop");

Python

# A note, not output
print("State:", "ready")
print("Don't stop")

What changes

Python print separates multiple arguments with spaces and ends with a newline. Unlike C#, both single and double quotes delimit strings; a one-character Python string is still str, not char. An f-string such as f"Count: {3}" plays a role similar to C# string interpolation. The hash begins a comment only outside a string.

Transfer mistake

C# // comments become Python # comments. Python // means floor division. Do not add diagnostic output to an exact-output task.

Your task

Read one line of text, including an empty line or text containing quotes or #. Output Message:, a space, and the unchanged input on line one; output It's Python on line two. Replace the starter diagnostic with the required line. The provided input() reads the line without its ending newline.

challenge icon

Challenge

Beginner

Read one line of text, including an empty line or text containing quotes or #. Output Message:, a space, and the unchanged input on line one; output It's Python on line two. Replace the starter diagnostic with the required line. The provided input() reads the line without its ending newline.

Editable implementation files: main.py. The locked driver.py is the supplied launcher or input/output harness and must remain unchanged.

Use the supplied input contract without prompts. Print only the required lines, each ending in a newline.

Try it yourself

# Starts the program in main.py. Edit main.py to solve the challenge.
from runpy import run_module

run_module("main", run_name="__main__")
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Python for C# Developers

Practice on your own: Online Python compiler