Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Comments | Comments
Python Tutorial for Beginners

book
Comments

Comments are lines of text in your code that Python ignores because they are for people, not machines. In most cases, comments are created to explain a piece of code so that another programmer who will watch the code can understand it.

# This is a comment
# Python ignores it
print("Hello, kittens!")
123
# This is a comment # Python ignores it print("Hello, kittens!")
copy

Comments begin with #, and after this you write the text you need. Let's take another example:

# Creating variables
number_1 = 65
number_2 = 30
# Addition of two numbers
sum_=number_1 + number_2
# Displaying the result on the screen
print(sum_)
1234567
# Creating variables number_1 = 65 number_2 = 30 # Addition of two numbers sum_=number_1 + number_2 # Displaying the result on the screen print(sum_)
copy

In the code above, Python displays the message and ignores the comment.

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 1

Spørg AI

expand
ChatGPT

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

some-alt