Python 1
Python 1
What is Python?
Python is an object-oriented programming language that is
designed in C.
it is a high-level programming language that allows for the creation
of both simple as well as complex operations.
Along with this ,Python comes inbuilt with a wide array of modules as
well as libraries which allows it to support many different
programming languages like Java, C, and C++
Python Features
1. Easy to code:
Python is a high-level programming language. It is very easy to learn the
language as compared to other languages like C, C#, Javascript, Java, etc. It is
also a developer-friendly language.
2. Free and Open Source:
Python language is freely available at the official website .Since it is open-source, this
means that source code is also available to the public. So you can download it as,
use it as well as share it.
3. Object-Oriented Language:
One of the key features of python is Object-Oriented programming. Python supports
object-oriented language and concepts of classes, objects encapsulation, etc
4. GUI Programming Support:
GUI or Graphical User Interface is one of the key aspects of any programming
language because it has the ability to add flair to code and make the results
more visual. Python has support for a wide array of GUIs which can easily be imported
to the interpreter, thus making this one of the most favorite languages for developers.
Graphical User interfaces can be made using a module such as PyQt5, PyQt4,
wxPython, or Tk in python.
Python Features
print ("hello world"); #here, we have used print() function to print the
message on the console.
Statements and Syntax
Comments ( # )
Python comment statements begin with the pound sign or hash symbol
(#).
A comment can begin anywhere on a line. All characters following the
# to the end of the line are ignored by the interpreter
Continuation ( \ )
Python statements are, in general, delimited by NEWLINEs, meaning one
statement per line.
Single statements can be broken up into multiple lines by use of the
backslash.
if (a == 1) and \
(b == 0):
Print(“msg”)
Statements and Syntax
There are two exceptions where lines can be continued without backslashes.
A single statement can take up more than one line when enclosing
operators are used, i.e., parentheses, square brackets, or braces, and when
NEWLINEs are contained in strings enclosed in triple quotes.
# display a string with triple quotes
print '''hi there, this is a long message for you
that goes over multiple lines... you will find
out soon that triple quotes in Python allows
this kind of fun! it is like a day on the beach!'''
# set some variables
go_surf, get_a_tan_while, boat_size, toll_money = (1,
'windsurfing', 40.0, -2.00)
Statements and Syntax
Multiple Statement Groups as Suites ( : )
Groups of individual statements making up a single code block are
called “suites” in Python.
Compound or complex statements, such as if, while, def, and class,
are those that require a header line and a suite.
Header lines begin the statement (with the keyword) and terminate
with a colon ( : ) and are followed by one or more lines that make
up the suite.
Statements and Syntax
Suites Delimited via Indentation
Python employs indentation as a means of delimiting blocks of code.
Code at inner levels are indented via spaces or tabs.
Indentation requires exact indentation; in other words, all the lines of
code in a suite must be indented at the exact same level (e.g., same
number of spaces).
if (a == 1) and (b == 0):
c= a+b
Print(“msg”)