This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c = np.array([[1,2] , [3,4]]) | |
print(c) | |
#[Output]: | |
#[[1 2] | |
# [3 4]] | |
print(c.shape) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
a = np.array([1.,2.,3.]) | |
print(a.shape) | |
b = np.array([[1.,2.,3.]]) | |
print(b.shape) | |
#[output]: | |
#(3,) | |
#(1, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c = 0 | |
tic = time.time() | |
for i in range(1000000): | |
c += a[i]*b[i] | |
toc = time.time() | |
print("For loop " + str(1000*(toc-tic)) + "ms") | |
#[Output]: | |
#For loop 1236.6154193878174ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import Numpy in Python | |
import numpy as np | |
a = np.random.rand(5,1) | |
print(a) | |
#[Output]: | |
#[[0.28642857] | |
# [0.51330181] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Creating a cutom class with a special method __specialprint__ | |
class custom_class: | |
def __init__(self, name): | |
self.name = name | |
## Creating a special method which is just printing the name associated with the object | |
def __specialprint__(self): | |
print(self.name) | |
## Creating the object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Creating a range object | |
x = range(4) | |
## Printing that object | |
x | |
#[Output]: | |
#range(0, 4) | |
#Here, there is no next method associated with the range object. | |
#But if we will create a generator using range object then next()function will work because the generator has special method next. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Creating a string variable | |
b = 'Learn!' | |
## In this string value case str is giving output without '' but repr is giving output with '' | |
print(str(b)) | |
#[Output]: | |
#Learn! | |
## In this string value case str is giving output without '' but repr is giving output with '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Creating a variable contains numerical value | |
a = 1/9 | |
## printing that variable using str() then it will give simple output | |
## In this numerical value case both str and repr are giving same results. | |
print(str(a)) | |
#[Output]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INFO:root:office_hours function ran with args ('10:00', '18:00') and kwargs {} | |
INFO:root:new_employee function ran with args () and kwargs {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ company | |
def new_employee(): | |
print('Hi! Welcome to Robofied team') | |
## This function will also work fine as our function can handle any no. of arguments - zero, one, two etc.. | |
new_employee() | |
#[Output]: | |
#Hi! Welcome to Robofied team |