Hello
everyone! Welcome to our channel HIGH-TECHDROID and this is Lavanya. Today, we
are going to see about Python Programming. Let me begin with it’s history.
Python was started to develop in the year of 1987 but it came to lime light
since 4-5 years.
History:
The major reason behind it is the non-availability of a proper community behind to develop and explore its features. Then, it’s features were being explored by major powers of the world like NASA, IBM, YouTube and Google and they began to develop their web applications using Python. Okay, let us get started by downloading and installing Python from the official website python.org. Before that, let you know that there are two versions of Python-Python 2.x and Python 3.x with sub-versions on each of them.
Download Page:
If you go to Chrome and type python.org, you could find the homepage of Python official website. Go to Downloads and click on All Releases. You could find the download link of Python version 3.7.1. to download and install it. In case, if you are using Windows XP or previous versions, then Python 3.5+ versions are not compatible. Hence, you can opt for Python 2.7, Python 3.4 and other such versions. There are no major differences between Python 2.x and Python 3.x except few while finding it easy to learn. Coming back, let’s have a look at it’s features. Python is human readable language that makes it a high level programming language and speaking about dynamic feature, user can modify it in run time as they wish. Next is object oriented.
Difference between java & python:
The best feature of Java is that it is totally an object-oriented one. Similarly, Python is also object-oriented with coding done based on an object. Next feature is lesser coding. We could throwback our memories of counting the number of pages before even reading the topic of the program. But python has saved us by its short and sweet nature. Next is, capability of automatic memory management.
You need not
do any specific actions regarding memory management as Python looks after it
right from variable to files for memory allocation. On the way, next is several
built-in ready-to-use libraries which is the major feature which on being
explored has made its way to various fields which will be discussed soon.
And
less complexity, Python is generally a less complex language and simple one to
learn so easily. Next is portability. Python allows its code to be run in
different environments. For example, if you write a piece of code in Linux
environment and want to export it to Windows environment, it is possible due to
the portable nature of Python. Interpretable feature- this is the major
difference between Java and Python. In Java, C or C++, we would compile the
code which would yield a class file that is run to get the output. This is
different, incase of Python as it interprets the code line-by-line and on
occurrence of error, it needs to be cleared to proceed further. And the final
one is embeddable. That is, python code can be embed in other languages like C
or C++.
Applications:
On learning Python, it is necessary that we should be aware of where we could use it. First is, Machine Learning, GUI development, Web applications development, Data analysis and Gaming. If you are interested in gaming, python will lead you to a bright future ahead. It is also used in the fields of Graphics and Computer vision which is regarding face recognition.
Major Differences:
Here is the
list of major differences between Python and Java. First is syntax. In Python,
syntax is so easy, whereas Java is so Descriptive due to its verbosity.
Indentation- Java has curly braces to define the scope whereas in Python, we
give a Tab space to define the scope. Next is Semi-colon.
There are none who
would have not missed the semi-colon. But in python we need not bother about it
as it is not required. Finally, it is Comment. We use # for single comment line
and ””” for multi-line comments. And verbosity, as already mentioned, Java is a
descriptive one. Will see it by first example,A sample class that is “class Classname”and within the main function
we had printed a statement “Hello
world”.Here in java to print a “Hello world”we need a class, main function and a print
statement and within that we also need to define a scope.so Java is so
descriptive in nature.
But python
is so simple within the single line code we can print “Hello world”.And
coming to protability both java and python are portable one.And
Dynamically-typied in this scenario java
and python differs majorly.In java if you need to use a object first you have
to declare it.But not in python here we can use it at a time.
While
coming to speed ofcourse Java is the fastest one,whereas in python interpretation occursso it takes more
time to interpretate line by line code.
Sample program:
Now,we will start to write a sample program in python . I had downloaded and inatalled the python 3.6.5.Ok As we seen the“Hello world”program in java,we will see it in python.This is a python IDE.We write a single line of code in this IDE also.See here a single line of code just if we give “Hello world”within the print function,sure it will print it.Here the main(), scope is not necessary.I think now you will be clear about the difference between java and the python.
Incase you are writing a set
of code and if you wish to save the file, Go to file->New file. A untitled
page/notepad will be opened,here you can write a set of code and save it also
you can run it whenver needed.
Ok we will see a sample
program
Saving the file with python extension:
Now we shall save a file,I am saving a file a hello.py “.py”extension is compulsory.Now I going to run the file,hello,py program is running now
Enter your name “My name is Lavanya”
Asking your number 12345
Program Explanation:
OUTPUT- see here “Your name is Lavanya and your contact is 122345” as I entered.Now going back to the program. See here this code just with in three lines of code you get a input and also you can print it. I had told about Dynamically-typed here I haven't mentioned any datatype for the name .According to the input the datatype will be automatically assigned by python,For example see here I had given enter ur name within input.
What’s my input
?? it a name given in string,python assing the datatype for the name as string
automatically.Next enter ur contact I
mention it as int because python may assign it as string so while giving int
the num is changed as integer data type .Now while printing within the print() I
given enter ur name with in double quotes usually we will give +in java but
here comma is required and I printed name and also a contact number.
Here is the video link presented of the above blog
That becomes the end of video,Thankyou for watching will see on next Blog.
04-11-2018