Python training | 5 Common Mistakes made by Python Beginners

Python training | 5 Common Mistakes made by Python Beginners

Python training programs are high in demand, and people everywhere are trying to learn the ins and outs of the language to take advantage of the great job opportunities. Often times programmers attempt to learn the language on their own, but it can often be quite challenging to get used to the simple differences between Python and other languages. Here are some of the common mistakes beginners to Python and programming in general tend to make.

Forgetting to use a colon at the end of a conditional statement

E.g. if num == 5

    print (‘num is equal to 5’)

For those new to Python or to programming in general, it is a very common mistake to omit the colon and will take a while before it becomes habitual. Doing so will stop the interpreter in its tracks and leave a very confused beginner with a vague error message stating ”SyntaxError: invalid syntax”.

Forgetting to open or close a quote

E.g. if num == 5:

    print(‘num is equal to 5)

Everyone makes typos, but omitting just one quote will cost you a runtime error (SyntaxError: EOL while scanning string literal) and precious time searching for the exact position where you missed the second quote.

Incorrect use of indentation

    E.g. if num == 5:

        print(‘num is equal to 5’)

            else:

            print(‘num is not equal to 5’)

Indentation will increase by one level after a colon. Make sure to indent correctly to avoid of of these three errors:

IndentationError: unexpected indent

IndentationError: unindent does not match any outer indentation level

IndentationError: expected an indented block

Incorrectly using “=”

E.g. if num = 5:

    print(‘num is equal to 5’)

The equal sign is used in Python to assign a value to a variable. If the equals sign is used for a comparison, a run time error will occur (SyntaxError: invalid syntax). In order to avoid this, you must use two equal signs (“==”) to signify that you are comparing two values and not equating them.

Attempting to use a keyword as a variable name

    E.g. print = ‘Hello’

Keywords are reserved and can therefore not be used as variable name or else you will be left with an error message (”SyntaxError: invalid syntax”). If your variable name was print, then how would you do a print command?

These common mistakes will reduce in quantity as you gain experience, and the quickest way to get experience is through training. Check out the Python courses offered by JBI to provide the highest quality Python training for your employees!

 

For more more information about our range of courses: 

     - Python Advanced Course

     - Python for Data Scientists Training

     - Angular 2 Training Course

Case Study: Angular training makes a difference to customer engagement.

Find out more

VIEW ALL CASE STUDIES