Sunday, May 23, 2021

Python - Modules, Comments & Pip

 Open the vs code and first install python extension

Let’s write our very first python program.

Create a file called and paste the below code in it

print(“Hello World”)         => print is a function (more later)

Execute this file (.py file) by typing python and you will see Hello World printed on the screen.


A module is a file containing code written by somebody else (usually) which can be imported and used in our programs.


Pip is a package manager for python. You can use pip to install a module on your system.

E.g. pip install flask (It will install flask module in your system)

Types of modules

There are two types of modules in Python:

Built-in modules – Pre-installed in Python

External modules – Need to install using pip

Some examples of built-in modules are os, abc, etc.

Some examples of external modules are TensorFlow, flask, etc.

Using Python as a Calculator

We can use python as a calculator by typing “python” + TO DO on the terminal. [It opens REPL or read evaluation print loop]


Comments are used to write something which the programmer does not want to execute.

Comments can be used to mark author name, date, etc.

Types of Comments:

There are two types of comments in python,

Single line comments – Written using # (pound/hash symbol)

Multi-line comments – Written using ‘’’ Comment ‘’’ or “”” Comment “””.


1. To print multiple lines in print function, you have to keep the multiple lines within the tripe quote  ''' or """.

print("""Twinkle, twinkle, little star,
How I wonder what you are.
Up above the world so high,
Like a diamond in the sky.
Twinkle, twinkle, little star,
How I wonder what you are!""")

2. How to import one external module and run on vs code:

run pip install playsound

from playsound import playsound
playsound('C:\\Users\\Srinanda\\Desktop\\python\\1. Chapter 1\\play.mp3')

3. Always Use labels in comments

4. How to print the contents of a directory using os module:

import os



import os


No comments:

Post a Comment

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...