Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære How to Use Comments for Readability | First Acquaintance with Python
Introduction to Python (dev copy)

bookHow to Use Comments for Readability

As your code grows in size, it can become challenging to understand each part, even if you're the author.

That's why it's necessary to get in the habit of leaving comments in your code. Comments help clarify the purpose or function of a specific code segment.

To designate a line as a comment, start it with the # symbol. If you put a # before the print() statement, that line won't run.

12
# print('Message 1') print('Message 2')
copy
question mark

How many lines will be displayed when you run the code below?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 2

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Suggested prompts:

Spørg mig spørgsmål om dette emne

Opsummér dette kapitel

Vis virkelige eksempler

Awesome!

Completion rate improved to 1.64

bookHow to Use Comments for Readability

Stryg for at vise menuen

As your code grows in size, it can become challenging to understand each part, even if you're the author.

That's why it's necessary to get in the habit of leaving comments in your code. Comments help clarify the purpose or function of a specific code segment.

To designate a line as a comment, start it with the # symbol. If you put a # before the print() statement, that line won't run.

12
# print('Message 1') print('Message 2')
copy
question mark

How many lines will be displayed when you run the code below?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 2
some-alt