Skip to main content

python beginners tutorial

Introduction 


Python is an interpreted, object orientedand high level programming language which uses dynamic semanticsthat means its data type can be changedduring the runtime. By design, python is seen as a readableand user-friendly language. It is a complete object-orientedprogramming language andit is pretty easy to use. 

In the late 1980s guido van rossumstarted its development. When mr. Guido was developing this languagehe was watching a show called"monty python circus"and while watching this show he thoughtof the name pythonand he named this language "python". He did this because he wanted to choose ashort and mysterious name for some reason. So he thought of naming it python only.

Till 12 july 2018, mr. Guido took theresponsibilityof developing and maintaining python alone. For a lead developer this work isvery appreciable and really hard. After 2018 mr. Guido announced hispermanentvacation from this role. After this python's core developers elected ateamof five persons that will lead python furthermr

 After this long journey ofpython development, today, python is one of the mostpreferred language. Python's development was goingon in the 1990'sand in 2000 python 2 was released. After that in 2008 python 3 was launched. With python 3, a utility named "2 to 3"was released which will help you convertyour python 2 code to python 3. Because of python's popularity, after 2008many people were still using python 2.7because they were very comfortable with itssyntax. And there were a lot of changes in python 3that were completely different from python 2 andbecause of learning inertia developers werenotswitching to python 3 . 


Python 2.7's end of life was announced in 2015 that meansafter this no update will be made for python 2. And all code development will be of python 3 only. Python 3.9.2 and 3.8.8 were two of theversionswhich were developed very quicklybecause there were some missing securityupdates in pythonand some vulnerabilities like remote codeexecutionand web cash poisoning were to be resolvedin previous versions. So these were some amazing facts related topython andnow let's come to the language.

Comment in python 



 And let's quickly see the syntax of python. To write comment in python you just need to use # symbol andafter that whatever you write in that singlelineis treated as comment and it won't be treated as a python code. For multiline comments you can usetriple quotes like thisand whatever you write inside it will becomment out. That means it won't be parsed and executed. 

Print function in Python 


There is a function called
print in pythonwhich is used to print astring/ number/ variablea print syntax is written like this in python 3and you can print anything your name, a float or an object. 

Arithmetic Operators


In python you can use arithmetic operators like this that will help you add, subtract, multiply ordivide.

 Variable  & Data type


To declare a variable, you can simply usevariable = value. If the value is a string usesingle or double quotesand triple quotes can be usedfor multiline strings. You can store a number like this. And a float like this. You can also change the datatype of a variable after declaring it.

Lists  in python 


To store values more than oneyou can use lists. Lists syntax is written withinsquare brackets like this. Lists can be changed anytime. In it you canappend values.

Tuple


 There is one more datatype like list in python but you can't change itthis datatype is known as tuple. You can write a tuple like this. It's values are separated by comma inside twoparentheses. To write a tuple with one value you need toput an extra comma . If i write a = ("1" , ) then it will make a tuple of one value. 

Dictionary in python 


We can use a dictionary to store a key value pair. Python is seen as a readable language anda friendly language for developersand beginners. And the dictionary in python is like a realoxford dictionary where you look forkey value pairs. Keys are the words and themeaning is the value. In python also you can create a dictionary like this. Its syntax could be written like this with thehelp of curly bracesand you can write the keyvalue pairs like this. Then to access the key value pair you can use this syntax. 

Set in python 

Python has one more collection called set. The main feature of set is that you can'thave duplicate values in ityou can initialize a set like this and if you type 1 then 2 andthen 3 and 9. Then your set wouldlook like this butif i insert 1 again then your set valuewon't change because this set already has 1. 

Set vs list

If i used list i would have gottenrepeated values but set help us when wewant to restrict repeated values

None in python 


like that you can use none value to representnothing. You can write none like this. 

Boolean 


Boolean values can be used to store true and false. If your variable has true or false value you can write like this.

Conditional statement 


In python we have an if else syntax like this. You can write if/ else like thisand you can use if, elif, elif, else likethis to make if else ladder. Inside if you need to write a condition which will be evaluated to true or false, if it's true it will go in if and if it's false it willgo to else or it will check the condition of elif. 

Function in python


 If you want to make a function in python you use def keyword like this. Inside a function you may return a value. Ifnothing is returned then none is returned. This is the same none
which we learnedabout earlier .

Modules in python 


The most beautiful thing aboutpython is modules. Many people have written alot of code inpython which you can use by importing it. And you will import this code inform of a module. We have this syntax for importing in python. These modules are of two types built inand external modules. Built in modules are already there in python. You don't need to download it. But the external modules needs to be installed from pip or any other tool. So that you can use the code from someoneelse in your computer and python scriptthis code is formatted asclasses and functions. When you will be advanced in python. You may make your own moduleand publish it also so that others can use it. 

Oops in python 



Python is an object oriented programminglanguage. That means you can use classes and objectand also use objects oriented paradigm. Object oriented programming means that you can make objects from a classwhich is a blueprint. If i take an empty form as a class, then i willtake individually filled forms as an object. Objects formed from this class. You can make your own custom classes andinherit already defined classes to change our classand you can do all this work in python'sawesome and easy to use syntax.So this was a brief on python.

Conclusion 

So that's it for today. Thank you so muchguys for reading  this article . And i will see you next time. 

Watch this also



Comments

Popular posts from this blog

Is dark mode good for your eyes

  In this post you know that " is dark mode good for your eyes " and we solve all your query about dark mode What is dark mode ? Dark mode is feature in Android and ios this feature provide a black theme for your Android and IOS.   What is the benefit of Dark mode? Battery performance If you turn on dark mode in your phone then it's boost your battery life and battery backup Good for your eyes Dark mode doesn't harm your eyes it provides you a comfortable experience  with your phone Dark mode vs Light mode Dark mode Dark mode is basically light text showing up in a dark screen. Light mode Light mode is default in your phone its a dark text showing up in a light screen know as "light mode". Is dark mode good for your eyes Is dark mode better for your eyes? While dark mode has a lot of benefits, it may be better for your eyes. Using dark mode is helpful in that it's easier on the eyes than a stark, bright white screen. However, using a dark sc...

Fact about iphone

  In this article you know 6 interesting fact about iphone that could wandered you. 1) You notice that evrey iphone have same time "9:41".The story behind it " Steve Jobs launch her first iphone on time-"9:41". In 2007  iphone 1 got invention of the year from times magazines.  You see that tow big companies samsung and Apple always competite each other but you know the processor Of iphone made by samsung.  iPhone’s prices in Brazil is significantly higher than in the United States. They consider iPhone as such a luxurious thing that it includes many taxes which made the price double of it. The first iphone was not made by apple actually Cisco already register the name iphone. Cisco is a voice over ip service provider to make calls. When Apple make her phone name iphone Cisco also case to apple It wondered you that the siri voice assistant store your all voice command to 2 year and it will be use for analysis and make better to siri.