Python Basics
Python Basics
GEOSPATIAL DATA
• You can get the data type of a Python variable using the
python built-in function type() as follows:
Python Fundamentals
Python –Casting a Variable
• You can specify the data type of a variable with the help
of casting as follows:
Python Fundamentals
Python –Variable Multiple
Assignment
• Python allows to initialize Instead of separate
more than one variables assignments, you can do it in a
in a single statement. In single assignment statement as
the following case, three follows
variables have same value. >>> a=b=c=10
>>> print (a,b,c)
• >>> a=10 10 10 10
• >>> b=10
• >>> c=10
Python Fundamentals
Taking input in Python
• input (): This function first takes the input from the user
and converts it into a string. The type of the returned
object always will be <class ‘str’>.
• It does not evaluate the expression it just returns the
complete statement as String.
• Syntax:
• Example:
Python Fundamentals
How the input function works in
Python
• When input() function executes program flow will be stopped
until the user has given input.
• The text or message displayed on the output screen to ask a
user to enter an input value is optional i.e. the prompt, which
will be printed on the screen is optional.
• Whatever you enter as input, the input function converts it into
a string. if you enter an integer value still input() function
converts it into a string. You need to explicitly convert it into an
integer in your code using typecasting .
Python Fundamentals
How the input function works in
Python
• raw_input(): This function works in older version (like Python
2.x). This function takes exactly what is typed from the
keyboard, converts it to string, and then returns it to the
variable in which we want to store it.
QUESTIONS?