# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/trkonduri/handson-ml/blob/master/Python_in_a_Minute.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + [markdown] id="pKS1-91DmQu7" colab_type="text"
# ---
# [![Linkedin](https://content.linkedin.com/content/dam/brand/site/img/logo/logo-r.png =120x) Join group for discussion on Machine Learning](https://www.linkedin.com/groups/13570295) 
#
# ---
# # License
# Copyright © 2018, <NAME>. Paripath Inc.
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the [GNU General Public License](www.gnu.org/licenses/gpl-3.0.html) for more details.

# + [markdown] id="4lxTEugemGKi" colab_type="toc"
# >[License](#scrollTo=pKS1-91DmQu7)
#
# >[Introduction](#scrollTo=XJP2UJYTgQdl)
#
# >[Basics](#scrollTo=QsN9fR1YfZaO)
#
# >>[Comments](#scrollTo=QsN9fR1YfZaO)
#
# >>[Numbers](#scrollTo=-dm6YzkDft03)
#
# >>[String](#scrollTo=-1Xm7AgRf5Zp)
#
# >>[None Object](#scrollTo=4_uiBSb4gI6L)
#
# >>[Type Casting](#scrollTo=XYwZAm3rgPVL)
#
# >>[Display](#scrollTo=XQq5kLhxgR91)
#
# >>[Arithmatic](#scrollTo=FSqWpVd6gZIc)
#
# >>[Comparision operators](#scrollTo=yFTLg_BsggoK)
#
# >[Statements](#scrollTo=kIMHPi4ZgxFZ)
#
# >>[If Statement](#scrollTo=kIMHPi4ZgxFZ)
#
# >>[Loops](#scrollTo=beQA0DA9g9vL)
#
# >>[Controlling Loops](#scrollTo=jM57KTIfhjOb)
#
# >[Data types](#scrollTo=1W3-BCTan0ZG)
#
# >>[List](#scrollTo=hnPA9NyCjfiN)
#
# >>[Tuple](#scrollTo=1r4In-DWjkFu)
#
# >>[Dictionary](#scrollTo=ONaz9gHXjl6J)
#
# >[Functions](#scrollTo=lU9_cn6vjuVR)
#
# >[Slicing](#scrollTo=17JvCRqEjxKt)
#
# >[Credit:](#scrollTo=D3n9BLpQlaTX)
#
#

# + [markdown] id="RX4XNQ2RmPu_" colab_type="text"
#

# + [markdown] id="XJP2UJYTgQdl" colab_type="text"
# # Introduction
#
# Python is 
# strongly typed (i.e. types are enforced), dynamically, implicitly typed (i.e. you don’t have to declare variables), case sensitive (i.e. var and VAR are two different variables) and object-oriented (i.e. everything is an object).
#
# 1. strongly typed (types are checked and enforced)
# 2. implicitely typed (no declaration needed)
# 3. case sensitive (python and PYTHON are two different variables)
# 4. object oriented
#
#

# + id="NDKvRhNqudZF" colab_type="code" colab={}
help(14083727405); # Paripath phone number
# returns Help on int object:

# + id="NoxwsgmgibEk" colab_type="code" colab={}
# return string object's methods
dir("www.paripath.com");

# + id="B2isRuOli9mQ" colab_type="code" colab={}
# inlined documentation on function len()
len.__doc__

# + [markdown] id="QsN9fR1YfZaO" colab_type="text"
# # Basics
# ## Comments

# + id="eFGHV9KyfchF" colab_type="code" colab={}
# comments
''' multiline comments '''

# + [markdown] id="-dm6YzkDft03" colab_type="text"
# ## Numbers

# + id="uJstZCV0f1q2" colab_type="code" colab={}
sample_int = 1
sample_float = 3.14

# + [markdown] id="-1Xm7AgRf5Zp" colab_type="text"
# ## String

# + id="ivJ__9Buf-ES" colab_type="code" colab={}
str1 = "This book"; # double quotes
str1 += ' is on Machine Intelligence.'; # single quotes

# + [markdown] id="4_uiBSb4gI6L" colab_type="text"
# ## None Object

# + id="amnvL4f8gLOV" colab_type="code" colab={}
errors = None ; # empty value

# + [markdown] id="XYwZAm3rgPVL" colab_type="text"
# ## Type Casting

# + id="bBdmMTjMgRRp" colab_type="code" colab={}
int_cast   = int(3.14)
float_cast = float('2.71828')
str_cast   = str(3.14)

# + [markdown] id="XQq5kLhxgR91" colab_type="text"
# ## Display

# + id="8rOcNUiLgVQN" colab_type="code" colab={}
print("This is me")

# + [markdown] id="FSqWpVd6gZIc" colab_type="text"
# ## Arithmatic

# + id="SFTUIItLgb21" colab_type="code" colab={}
x = 2;       # assignment
x = x + 2;   # addition
x += 2;      # addition
x = x-3;     # subtraction
y = 3.14*x;  # multiplication
y = y/2;     # division
y = y%2;     # remaidner
z = 2.71**2; # power

# + [markdown] id="yFTLg_BsggoK" colab_type="text"
# ## Comparision operators
# * equal ==
# * not equal !=
# * less <
# * less equal <=
# * greater >
# * greater equal >=

# + [markdown] id="kIMHPi4ZgxFZ" colab_type="text"
# # Statements
# ## If Statement

# + id="gr7uAhIZg1H7" colab_type="code" colab={}
if 'I am' == 'me':
  print ("me")
elif "you" == "U":
	print ("you")
else:
	print ("them")

# + [markdown] id="beQA0DA9g9vL" colab_type="text"
# ## Loops

# + id="ah9zOVj-g_XG" colab_type="code" colab={}
# count to 10
i=0
while (i<=10):
  print(i, end=' ')
  i += 1;

print('\n')

# count to 10
for i in range(0,11):
  print(i, end=' ')


# + [markdown] id="jM57KTIfhjOb" colab_type="text"
# ## Controlling Loops
#
# 1. break
# 2. continue

# + id="6pcHdoxqhnU4" colab_type="code" colab={}
i = 0
while (True):
  i += 1;

  # Use of continue
  if ( i==1 ):
    print('starting ... ')
    print(i, end=' ')
    continue ;

  print(i, end=' ')

  # Use of break
  if ( i > 10 ):
    print('\nending.')
    break;

# + [markdown] id="1W3-BCTan0ZG" colab_type="text"
# # Data types
#
#
# 1.   List
# 2.   Tuples 
# 3.   Dictionary 

# + [markdown] id="hnPA9NyCjfiN" colab_type="text"
# ## List

# + id="SkG85P-YobT3" colab_type="code" colab={}
word_list1 = ['This', 'book', 'is']
word_list2 = ['on', 'Machine', 'Intelligence']
word_list  = word_list1 + word_list2 ; # list concat
word_list.append('.')
word_list.sort()
word_list.remove('Intelligence')

# + [markdown] id="1r4In-DWjkFu" colab_type="text"
# ## Tuple
# A sequence of immutable Python objects. Tuples are immutable which means you cannot update or change the values of tuple elements.

# + id="DHnk7LWCjloY" colab_type="code" colab={}
word_tuple = ('This', 'book', 'is', 'on', 'Machine', 'Intelligence')
print(word_tuple[5])

# + [markdown] id="ONaz9gHXjl6J" colab_type="text"
# ## Dictionary

# + id="KSOb6oKpjpHV" colab_type="code" colab={}
Book = {'title'  : 'Machine Intelligence in Design Automation',
        'Author' : '<NAME>',
		'isbn'   : 9781983974618,
		'pages'  : 212,
		'date'   : 'March 2018'
	}
print(Book['title'])

# + [markdown] id="lU9_cn6vjuVR" colab_type="text"
# # Functions

# + id="FDB2D-tUjvzj" colab_type="code" colab={}
global_str = Book['title']
def function_name (arg1, arg2):
	local_str = Book['Author']
	print (global_str + ' by ' + local_str)
	return arg2*arg1

print(function_name('is a unique book.', 1))

# + [markdown] id="17JvCRqEjxKt" colab_type="text"
# # Slicing

# + id="0OCcwaTokib5" colab_type="code" colab={}
global_str[0];   # 'M'
global_str[0:7]; # 'Machine'
global_str[:20]; # 'Machine Intelligence'
global_str[24:]; # 'Design Automation'\

# + [markdown] id="v6smmZmEtUrt" colab_type="text"
# # Exercise
# 1. What is the output of string slice global_str[8:]?
# 2. Write a python program to perform element-wise multiplication of two vectors.
#
# ---
# [![Linkedin](https://content.linkedin.com/content/dam/brand/site/img/logo/logo-r.png =120x) Join group for discussion on Machine Learning](https://www.linkedin.com/groups/13570295) 
#
# ---

# + [markdown] id="D3n9BLpQlaTX" colab_type="text"
# # Credit:
#
# [Machine Intelligence in Design Automation](amzn.to/2paZ53b)
#
# ---
#
# [![Machine Intelligence in Design Automation](https://qph.ec.quoracdn.net/main-qimg-be4b2dd87b0ef610f4fda06b89904bd5)](http://amzn.to/2paZ53b)

StarcoderdataJupyterScriptsDedupFiltered