APPLICATION DEVELOPMENT LAB Notes cts4
APPLICATION DEVELOPMENT LAB Notes cts4
Python Introduction
Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.
It is used for:
web development (server-side),
software development,
mathematics,
system scripting.
Python can do
Python can be used on a server to create web applications.
Python can be used alongside software to create workflows.
Python can connect to database systems. It can also read and modify files.
Why Python?
Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
Python has a simple syntax similar to the English language.
Python has syntax that allows developers to write programs with fewer lines than some other programming
languages.
Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means
that prototyping can be very quick.
Python can be treated in a procedural way, an object-oriented way or a functional way.
Good to know
The most recent major version of Python is Python 3.
Python will be written in a text editor.
Features of python
gedit filename.py
python3 filename.py
VARIABLES, EXPRESSIONS AND STATEMENTS After understanding some important concepts about
programming and programming languages, we will now move on to learn Python as a programming
language with its syntax and constructs. Values and Types A value is one of the basic things a
program works with.
. Each value in Python has a type. Type of 2 is integer; type of 10.5 is floating point number
“Hello” is string etc. The type of a value can be checked using type function as shown below
>>> type("hello")
<class ‘ str’>
>>> type(3)
<class ‘ int’>
>>> type(10.5)
<class ‘ float’>
>>> type("15")
<class ‘ str’>
Variables may take value that can be modified wherever required in the program.
Note that, in Python, a variable need not be declared with a specific type before its usage.
Whenever we want a variable, just use it. The type of it will be decided by the value assigned to
it. A value can be assigned to a variable using assignment operator (=)
>>> x=10
>>> print(x) 10 #output
>>> y="hi"
It is observed from above examples that the value assigned to variable determines the type of that
variable.
Variable Names and Keywords It is a good programming practice to name the variable such that
its name indicates its purpose in the program