Python — Output, Input, Modules and Comments

Amit Kumar
2 min readDec 12, 2022

--

Python is a programming language used for coding and scripting. And you don’t have to be a professional developer to succeed in Cybersecurity. The important thing is you should understand what you are seeing and know how to read code.

Showing output to the User

print("Hello World")

print("Content that you wanna print on screen")

Taking input from the User

name = input()

name = input("Enter your Name: ")

Note that, output of input() function will be always a string; means value stored in name variable above will be of string type, even if the value entered is numeric.

We can execute a python script by writing python3 script_name.py or ./script_name.py directly in the terminal. And we must write #!/bin/python3 in the first line of the script itself. In the first method, it will be interpreted as a comment, but in the second, it will tell the script where to execute, so our script can run properly.

Modules

The module is a piece of code written by someone, which can be imported and used in our programs. We have two types of modules in python i.e. Builtin and External.

Built-in modules are preinstalled in python like os, sys, time etc. And External modules are installed using PIP like flask, tensorflow and many more. PIP is a package manager for python used to install modules on our system. The syntax for using PIP is pip install module_name .

Comments

Comments are used to make code more understandable for programmers. They are not executed by the compiler or interpreter. There are two types of comments in python, i.e. single-line and multi-line comments.

#This is a sigle line comment

'''This is a
Multiline comment'''

--

--