Day 13 : Basics of Python

Day 13 : Basics of Python

What is Python?

  • Python is an Open source, general-purpose, high-level, and object-oriented programming language.

  • It was created by Guido van Rossum.

  • Python consists of vast libraries and various frameworks like Django, Tensorflow, Flask, Pandas, Keras etc.

How to Install Python?

You can install Python in your System whether it is Windows, MacOS, ubuntu, centos etc.

Task

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

2.Read about different Data Types in Python

In Python programming, data types are classes and variables are instances (objects) of these classes. The following are the built-in data types in Python:

  • Numeric

  • Sequence Type

  • Boolean

  • Set

  • Dictionary

  • Binary Types

Python Data Types {Comprehensive Overview}

Numeric Data Type in Python :

The numeric data type in Python represents the data that has a numeric value. A numeric value can be an integer, a floating number, or even a complex number.

  • 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.

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

Sequence Data Type in Python:

The sequence Data Type in Python is the ordered collection of similar or different data types. Sequences allow storing of multiple values in an organized and efficient fashion. There are several sequence types in Python –

  • Python String

  • Python List

  • Python Tuple

1. String Data Type: Strings in Python 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.

2.List Data Type: Lists are just like 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.

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

Boolean Data Type in Python:

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). However non-Boolean objects can be evaluated in a Boolean context as well and determined to be true or false. It is denoted by the class bool.

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

Set Data Type in Python:

In Python, a Set is an unordered collection of data types 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.

Dictionary Data Type in Python:

A dictionary in Python is an unordered collection of data values, used to store data values like a map, unlike other Data Types that hold only a single value as an element, a Dictionary holds a key: value pair. Key-value is provided in the dictionary to make it more optimized. Each key-value pair in a Dictionary is separated by a colon : whereas each key is separated by a ‘comma’.

Binary Data Type in Python:

The byte and byte arrays are used to manipulate binary data in Python. These bytes and byte arrays are supported by a buffer protocol, named memory view. The memory view can access the memory of another binary object without copying the actual data.