Skip to main content

Programming Tutorial

PYTHON TUTORIAL


Python tutorial provides basic and advanced concepts of Python. Our Python tutorial is designed for beginners and professionals.

Python is a simple, general purpose, high level, and object-oriented programming language.

Python is an interpreted scripting language also. Guido Van Rossum is known as the founder of Python programming.


Our Python tutorial includes all topics of Python Programming such as installation, control statements, Strings, Lists, TuplesDictionary, Modules, Exceptions, Date and Time, File I/O, Programs, etc. There are also given Python interview questions to help you better understand Python Programming.

What is Python

Python is a general purpose, dynamic, high-level, and interpreted programming language. It supports Object Oriented programming approach to develop applications. It is simple and easy to learn and provides lots of high-level data structures.

Python is easy to learn yet powerful and versatile scripting language, which makes it attractive for Application Development.

Python's syntax and dynamic typing with its interpreted nature make it an ideal language for scripting and rapid application development.

Python supports multiple programming pattern, including object-oriented, imperative, and functional or procedural programming styles.

Python is not intended to work in a particular area, such as web programming. That is why it is known as multipurpose programming language because it can be used with web, enterprise, 3D CAD, etc.

We don't need to use data types to declare variable because it is dynamically typed so we can write a=10 to assign an integer value in an integer variable.

Python makes the development and debugging fast because there is no compilation step included in Python development, and edit-test-debug cycle is very fast.

Python 2 vs. Python 3

In most of the programming languages, whenever a new version releases, it supports the features and syntax of the existing version of the language, therefore, it is easier for the projects to switch in the newer version. However, in the case of Python, the two versions Python 2 and Python 3 are very much different from each other.

A list of differences between Python 2 and Python 3 are given below:

  1. Python 2 uses print as a statement and used as print "something" to print some string on the console. On the other hand, Python 3 uses print as a function and used as print("something") to print something on the console.
  2. Python 2 uses the function raw_input() to accept the user's input. It returns the string representing the value, which is typed by the user. To convert it into the integer, we need to use the int() function in Python. On the other hand, Python 3 uses input() function which automatically interpreted the type of input entered by the user. However, we can cast this value to any type by using primitive functions (int(), str(), etc.).
  3. In Python 2, the implicit string type is ASCII, whereas, in Python 3, the implicit string type is Unicode.
  4. Python 3 doesn't contain the xrange() function of Python 2. The xrange() is the variant of range() function which returns a xrange object that works similar to Java iterator. The range() returns a list for example the function range(0,3) contains 0, 1, 2.
  5. There is also a small change made in Exception handling in Python 3. It defines a keyword as which is necessary to be used. We will discuss it in Exception handling section of Python programming tutorial.
SEE THIS EXAMPLE

Python Program to check if a Number is Positive, Negative or Zero

We can use a Python program to distinguish that if a number is positive, negative or zero.

Positive Numbers: A number is known as a positive number if it has a greater value than zero. i.e. 1, 2, 3, 4 etc.

Negative Numbers: A number is known as a negative number if it has a lesser value than zero. i.e. -1, -2, -3, -4 etc.Python Condition And Loops1

See this example:

  1. num = float(input("Enter a number: "))  
  2.   
  3. if num > 0:  
  4.  print("{0} is a positive number".format(num))  
  5. elif num == 0:  
  6.    print("{0} is zero".format(num))   
  7. else:  
  8.    print("{0} is negative number".format(num)) 

EXAMPLE:

Python Condition And Loops2


Note:In the above example, elif statement is used. The elif statement is used to check multiple expressions for TRUE and executes a block of code when one of the conditions becomes TRUE.

It is always followed by if statement.


Comments

Popular posts from this blog

Social Responsibililty

                                                                        SOCIAL RESPONSIBILITY Social Responsiblity   is an ethical framework and suggests that an entity, be it an organization or individual, has an obligation to act for the benefit of society at large.  Social responsibility  is a duty every individual has to perform so as to maintain a balance between the economy and the ecosystems.  4 Types of Social Responsibility Corporate Environmental Responsibility. ... Corporate Human Rights Responsibility. ... Corporate Philanthropic Responsibility. ... Corporate Economic Responsibility. Some of the common Responsibility for example given below: Reducing carbon footprints. Improving labor policies. Participating in fair trade. Charitable givin...

Remote Working: Mitigating Risks, Improving Productivity

  Business as usual for organizations the world over has been marred by these extraordinary times. An unprecedented crisis, the COVID-19 pandemic has divided our timeline into pre and post COVID eras.  Some of the business practices that have been prevalent until now may cease to exist or get an upgrade in the post COVID times. Business Continuity Planning: A Change in Approach Ever since 9/11, business continuity planning (BCP) has been an integral part of businesses across industries, especially in the banking and financial services sector. Split or multi-site processing, hot-warm-cold sites, work transfer, and staff transfer were some of the recovery strategies put in place to handle exigencies on ‘off’ days.  Although tested periodically for operational effectiveness, these strategies could not replicate the surprise – in fact, shock – element of real-world contingencies. After having delivered effective results for more than a decade, some events of significant propo...

4 Useful And New WhatsApp Features That Released During The COVID-19 Lockdown

  WhatsApp is one of the worlds largest online texting applications which is used almost in every country.  It is a light and easy to use texting application which also offers a lot of other important utilities other than texting.  These include video calling, group video calling, digital payments, document and media sharing and location sharing.  What began as a simple texting application is now an indispensable part of our lives because WhatsApp has made information flow faster and safer.  WhatsApp   web kept scaling new heights time and again and this was possible only because of the constant innovation by the developer team. In light of the COVID-19 pandemic which forced entire countries to go into lockdown and shut down businesses, WhatsApp is doing its part to help people during these times by rolling out some nifty and important features. Group video call limit increased  WhatsApp had the facility for group video calls which could only accom...