Common Mistakes

Week 2 - Introduction to Python

1. Comments

You can use just hash (#) for short comments or if it's multiple lines long you can comment in between triple quotation marks.
For most of the editors, apostrophes also work.

# this is a one line comment.


""" <== check number of " character

this is line 1 of many lines of comment.

second line of comment.

another line of comment.

"""

2. Using or Not Using Parentheses

No parentheses around the power results in the computation being a division by two.

# The aim is to obtain the square root:

x**1/2      #--> x/2

x**(1/2)    #--> sqrt(x)

3. log() or ln()

import math

# Logarithm of x with base e (natural logarithm)

math.log(x) #--> ln(x)

# Logarithm of x with respect to a specific base:

math.log(x, base) #--> log_base(x)