Posts by [email protected] (24)

Comments

<h2>Single-line comments</h2> <p>Comments are lines of code that are not read by Python. It is used to make code simpler and more readable.</p> <p>This is particularly useful when you are in a big development team and all of your colleagues are working on the same project.</p> <p>If one of your colleagues didn't understand a piece of code you wrote, comments can help!</p> <p>Comments are considered as one of the best practices of any programming language, not only in Python.</p> <p>Lines that begin with <code>#</code> aren't read by Python.</p> <div class="kodeEditor"># This is a comment # I'm printing my name down below. print('My name is Joe.') </div> <h2>Multi-line comments</h2> <p>We've learned that we can write comments in one line, but what if you've got an entire paragraph to tell your colleagues about a piece of code?</p> <p>To write comments as long as <i>The Order of the Phoenix</i>, all you have to do is enclose a paragraph or a story or anything inside a pair of triple quotes, just like the ones we've used to print a paragraph to the console.</p> <div class="kodeEditor">""" Lorem ipsum dolor sit amet consectetur, adipisicing elit. Error, accusantium aliquid modi pariatur quae asperiores aliquam facilis iusto repellat et veniam alias rerum debitis doloremque dicta vitae consectetur, maiores esse! """</div> <p>Next up: <a href="https://freekode.centeltech.com/course/266/" style="color:#007bff;">Concatenation</a></p>

Escaping Characters

<p>Assume that you're writing a story, and you need to use quotes inside of the story. If you put quotes inside of a sentence, you're going to get an error.</p> <p>So, how do we use quotes then?</p> <p>We can use quotes inside sentences because of a feature called escaping characters. If we put a backslash before the beginning quote in a sentence in a print function and the ending quote in the sentence in the print function, you can use quotes inside a sentence!</p> <p>You probably didn't understand that, so here's an example.</p> <div class="kodeEditor">print("Captain Haddock yelled \"Billions of billious blue blistering barnacles!\".") </div> <p>Next up: <a href="https://freekode.centeltech.com/course/265/" style="color: #007bff;">Comments</a></p>

First Previous 1 2 3 4 Next Last