Day13: Getting started with Python
What is Python?
Python is Open source, general purpose, high-level, and object-oriented programming language.
Guido van Rossum developed Python
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 window, MacOS, ubuntu, centos etc. Below are the links for the installation:
Ubuntu: apt-get install python3.6
Task1:
1. Install Python in your respective OS, and check the version.
Follow the installation steps for an ubuntu machine
1)sudo apt-get update
- sudo apt-get install python3.
3)sudo apt install python3-pip
4)python3 --version
Now you have successfully installed Python on your ubuntu machine.
2. Read about different Data Types in Python.
1. Numeric Data Type
Numeric data types: int, float, long, complex
Python numeric data type is used to hold numeric values like;
int - holds signed integers of non-limited length. ex=10
long- holds long integers(exists in Python 2.x, deprecated in Python 3.x).
float- holds floating precision numbers and it’s accurate up to 15 decimal places. ex=15.25
complex- holds complex numbers. ex=100+3j
2. Python String Data Type: Str
The string is a sequence of characters. Python supports Unicode characters. Generally, strings are represented by either single or double-quotes.
For example,
a = "string in a double quote"
b= 'string in a single quote'
print(a) print(b)
3. Python 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. Lists are mutable.
Lists in Python can be created by just placing the sequence inside the square brackets[].
For example,
1)list of having only integers
a= [1,2,3,4,5,6] print(a)
2)list of having only strings
b=["hello","sayali","tom"] print(b)
4. Python Tuple:
The tuple is another data type which is a sequence of data similar to a list. But it is immutable. That means data in a tuple is write-protected. Data in a tuple is written using parenthesis ( ) and commas.
For example,
#tuple having multiple type of data.
b=("hello", 1,2,3,"go")
print(b) #prints the whole tuple
5. Python 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.
For example,
a = {1:"first name",2:"last name", "age":33}
Thank you for reading!!Happy Learning!
Sayali