Table of contents
Let's begin with the basics of Python.
Python, what is it?
Python is a dynamically typed, general-purpose programming language that supports an object-oriented programming approach as well as a functional programming approach.
Python consists of vast libraries and various frameworks like Django, Tensorflow, Flask, Pandas, Keras, etc.
Python is an interpreted and high-level programming language but quite simple.
Created by Guido Van Rossum in 1989.
1. Installation of Python
For Windows
Go to this website: (https://www.python.org/downloads/)
Click on Download, the latest version of python (3.11.1) below
Check on the downloaded amd64.exe file and check on the checkbox at the bottom which says
add Python 3.11 to Path
Coming to the optimal feature window select all checkboxes
Now on the Advance option window, select the first 4 or 5 checkboxes as per our need and click on install.
Thus we successfully install Python on windows.
Search for "Idle Python" on windows
Check the version on the cmd(command prompt) or PowerShell :
python --version
For Ubuntu
Command : apt-get install python3.10
Check the version on the terminal: python -V
or python3 -V
2. Data Type
Data type specifies the type of value a variable holds. This is required in programming to do various operations without causing an error.
In python, we can print the type of any operator using type function:
a = 1
print(type(a))
b = "1"
print(type(b))
By default, python provides the following built-in data types:
Numeric data: int, float, complex
int: 3, -8, 0
float: 7.34, -9.0, 0.0001
complex: 6 + 2i
Text / String data: str
The string is a sequence of characters. Generally represented by single or double quotes.
str: "Hello World!!!", "Python Programming is simple"
Boolean data: bool
Boolean data consists of values True or False with capital ‘T’ and ‘F’
Sequenced data: list, tuple
list: A list is an ordered collection of data with elements separated by a comma and enclosed within square brackets.
e.g.: list1 = [8, 2.3, [-4, 5], ["apple", "banana"]]
print(list1)
O/p: [8, 2.3, [-4, 5], ['apple', 'banana']]
Tuple: A tuple is an ordered collection of data with elements separated by a comma and enclosed within
parentheses()
.e.g.: tuple1 = (("parrot", "sparrow"), ("Lion", "Tiger"))
print(tuple1)
O/p: (('parrot', 'sparrow'), ('Lion', 'Tiger'))
Mapped data: dict
dict: A dictionary is an unordered collection of data containing a key:value pair. The key:value pairs are enclosed within curly brackets.
e.g.: dict1 = {"name":"Santosh", "age":20, "canVote":True}
print(dict1)
O/p: {'name': 'Santosh', 'age': 20, 'canVote': True}
For more details on Python, watch the next blog !!
References videos: Data Types
Thanks for learning with me.
Enjoy python more! Have a nice day.