Hello there rinki here I am here with my tutorial for python, this tutorial is for absolute beginners who are confused about which language to begin with then python should be the first choice. Python is very robust and multipurpose language used from web development to machine learning and AI.
So ready to begin I urge you to first go and download python https://www.python.org/downloads/
Minute 1:
Go to python command line and try to print something
>>print(“Hello World”)
you printed your first python syntax
Next using Arithmetic operators
Start with printing this statements below:
>print(2+3)
>print(3–2)
>print(10%5)
>print(20//5)
These are few simple arthimetic operations
Minute 2:
Variables
name=”tecky geek”
>print(name)
o/p will give tecky geek
Boolean values respond to logical operators and / or
>>> True and False
False
>>> True and True
True
>>> False and True
False
>>> False or True
True
>>> False or False
False
Minute 3:
Datatypes in python
We can use the type()
function to know which class a variable or a value belongs to
1. Python Numbers
Integers, floating point numbers and complex numbers falls under python numbers category. They are defined as int
, float
and complex
class in Python.
>>a = 5
>>print(a, “is of type”, type(a))>>a = 2.0
>>>>print(a, “is of type”, type(a))>>a = 1+2j
>>print(a, “is complex number?”, isinstance(1+2j,complex))
o/p: 5 is of type <class ‘int’>
2.0 is of type <class ‘float’>
(1+2j) is complex number? True
2.Python Strings
String is sequence of Unicode characters. We can use single quotes or double quotes to represent strings. Multi-line strings can be denoted using triple quotes, '''
or """
.
>>> s = "This is a string"
>>> s = '''a multiline
Minute 4:
Datastructures in python
1.Python Tuple
Tuple is an ordered sequence of items same as list.The only difference is that tuples are immutable. Tuples once created cannot be modified.
>>t = (5,’program’, 1+3j)
2.Python set
Set is an unordered collection of unique items. Set is defined by values separated by comma inside braces { }. Items in a set are not ordered.
We can perform set operations like union, intersection on two sets. Set have unique values. They eliminate duplicates.
>>> a = {1,2,2,3,3,3}
>>> a
{1, 2, 3}
3.Python Dictionary
Dictionary is an unordered collection of key-value pairs
In Python, dictionaries are defined within braces {} with each item being a pair in the form key:value
. Key and value can be of any type.
>>> d = {1:'value','key':2}
>>> type(d)
<class 'dict'>
4.Python List
List is an ordered sequence of items. It is one of the most used datatype in Python and is very flexible. All the items in a list do not need to be of the same type.
>>a = [5,10,15,20,25,30,35,40]
Minute 5:
Ask yourself two questions
1)am i comfortable with python? if yes goto next question else close this TAB.
2)am i ready for learning new things in python?
if yes here you go to ride the awesome future to robust technology
- Firstly https://drive.google.com/file/d/15FNKqUgdyC9ZRcTfC3l_4EbGURArmBfz/view?usp=sharing go for this and give it a read
- Start with https://www.datacamp.com/courses/intro-to-python-for-data-science
- Along with this start practising by solving problem statements from http://codingbat.com/python as practice make man perfect its a old thought but worth if u get stuck can refer my solutions from https://github.com/eaglewarrior/codingbatsolutions-rinki my git hub repo.
And a good book to get started http://1.droppdf.com/files/5iHzx/automate-the-boring-stuff-with-python-2015-.pdf its a bible for python automation lovers.
So here we are ending our five minutes read to python till then take care and be tecky .