Back to Course

Introduction to Python

0% Complete
0/0 Steps
  1. Python: Basics
    14Topics
    |
    15 Quizzes
  2. Python: Control Flow
    12Topics
    |
    12 Quizzes
  3. Python: Errors
    5Topics
    |
    5 Quizzes
Lesson 1, Topic 1
In Progress

Python: Comments

Yasin Cakal 3 Oct 2021
Lesson Progress
0% Complete

Oddly, we will demonstrate how to instruct a computer to ignore a program section. A comment is a text that is written in a program but is not executed by the computer. Python considers anything following a # to be a comment.

Comments can help contextualize why something is written in a particular way, as shown below:

# This variables holds the number of cards in a deck.
deck_count = 52

Comments can assist other people reading the code in understanding it more quickly, as shown below:

# This code calculates the area of a rectangle
calculate_rectangle_area()

Comments allow for the omission of a line of code and the evaluation of how the program will run without it, as shown below:

# The code below has an error, it needs to be fixed:
# calculate_rectangle_area()

# But, the following code runs perfectly fine:
calculate_triangle_area()
%d bloggers like this: