Python input and import?

755    Asked by ElayneBalding in Data Science , Asked on Jan 4, 2020
Answered by Elayne Balding

Until now you saw that we did static programming means values were hard coded, but now we will learn how to pass values dynamically to any variable. To achieve this flexibility python has input() function. See below code for syntax

num = input("Enter your number:")

#output: Enter your number:

Import: when we are writing huge code its good practice to break codes in parts and define different modules. The module contains python definitions and statements with .py extension file and these modules can be imported into python interpreter using the import keyword.

For example, we can import the math module by writing below code

import math

And if you want to access functions defined within this module use below line:

from math import pi



Your Answer

Interviews

Parent Categories