Day-13 Task: Basics of Python

Day-13 Task: Basics of Python

Table of contents

No heading

No headings in the article.

What is Python Programming Language?

Python is a high-level, general-purpose, and very popular programming language. Python programming language (latest Python 3) is being used in web development, Machine Learning applications, along with all cutting-edge technology in Software Industry. Python Programming Language is very well suited for Beginners, also for experienced programmers with other programming languages like C++ and Java.

It was created by Guido van Rossum

The biggest strength of Python is huge collection of standard libraries which can be used for the following:

  • Machine Learning

  • GUI Applications (like Kivy, Tkinter, PyQt etc. )

  • Web frameworks like Django (used by YouTube, Instagram, Dropbox)

  • Image processing (like OpenCV, Pillow)

  • Web scraping (like Scrapy, BeautifulSoup, Selenium)

  • Test frameworks

  • Multimedia

  • Scientific computing

  • Text processing and many more...

How to Install Python?

You can install Python in your System whether it is Windows, MacOS, ubuntu, centos, etc. Below are the links for the installation:

Python Installation

Here we will install Python3 in the Ubuntu OS

Task:1

  1. Install Python in your respective OS, and check the version.

    To install python in ubuntu use the below command

    sudo apt-get install -y python3

    To check version

    python3 --version

  2. Data Types in python

    Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, data types are actually classes and variables are instances (objects) of these classes.

    Following are the standard or built-in data types of Python:

    1. Numeric Data Type:

      In Python, numeric data type represent the data which has numeric value. Numeric value can be integer, floating number or even complex numbers. These values are defined as int, float and complex class in Python.

      • integers – This value is represented by int class. It contains positive or negative whole numbers (without fractions or decimals). In Python, there is no limit to how long an integer value can be.

      • Float – This value is represented by the float class. It is a real number with a floating-point representation. It is specified by a decimal point. Optionally, the character e or E followed by a positive or negative integer may be appended to specify scientific notation.

      • Complex Numbers – Complex number is represented by a complex class. It is specified as (real part) + (imaginary part)j. For example – 2+3j

    2. Sequence Data Type:

      In Python, sequence is the ordered collection of similar or different data types. Sequences allows to store multiple values in an organized and efficient fashion. There are several sequence types in Python –

      • String - In Python, Strings are arrays of bytes representing Unicode characters. A string is a collection of one or more characters put in a single quote, double-quote or triple quote. In python there is no character data type, a character is a string of length one. It is represented by str class.

        Creating String-

        Strings in Python can be created using single quotes ' ' or double quotes " " or even triple quotes.""" """

      • List - Lists are just like the arrays, declared in other languages which is an ordered collection of data. It is very flexible as the items in a list do not need to be of the same type.
        Creating List-

        Lists in Python can be created by just placing the sequence inside the square brackets[].

      • Tuple- Just like list, tuple is also an ordered collection of Python objects. The only difference between tuple and list is that tuples are immutable i.e. tuples cannot be modified after it is created. It is represented by tuple class.

        Creating List-

        Lists in Python can be created by just placing the sequence inside the round brackets().

    3. Boolean Data Type:

      Data type with one of the two built-in values, True or False. Boolean objects that are equal to True are truthy (true), and those equal to False are falsy (false).

      Note – True and False with capital ‘T’ and ‘F’ are valid booleans otherwise python will throw an error.

    4. Set:

      In Python, a Set is an unordered collection of data type that is iterable, mutable, and has no duplicate elements. The order of elements in a set is undefined though it may consist of various elements.

      Creating Sets-

      Sets can be created by using the built-in set() function

    5. Dictionary:

      Python Dictionary is an unordered sequence of data of key-value pair form. It is similar to the hash table type. Dictionaries are written within curly braces in the form key:value. It is very useful to retrieve data in an optimized way among a large amount of data.

      Creating Dictionary-

      In Python, a Dictionary can be created by placing a sequence of elements within curly {} braces, separated by ‘comma’.

Thank you for reading the article

Happy Learning!