Hello World!, You are about the witness the beginning of an epic third coming of the 100-Day coding journey, A story that great sages will pass down from generation to generation. This quest will feature a potpourri of unfiltered joy, unrivaled pain, and unexpected epiphanies.
Some moments, I will be the smartest man alive. Others moments, I will be a stupid idiot. But each day, I will be a valiant warrior, fighting to develop and perfect the skills necessary to evolve into a true beast with these keys.
I have failed in my previous attempt for the challenge, which you can find here.
There are learning from the previous failure, here are the modification which was done to the challenge according to my handicap.
-
Selected the resource in advance,
-
Complete first 21 Days first.
Ladies and gentleman, I present to you, #100DaysofCode with @ animeshkbhadra
Day 45 | Thursday August 8,2019¶
Days Progress¶
- Always group the custom exceptions into a common module called exception in application.
- The custom exception class name should always end with error or exception, signifying the purpose.
Thoughts¶
Day 44 | Wednesday August 7,2019¶
Days Progress¶
- Error Specificity
- The order of catching
Exception
should be from specific to general. - The code should never be catching generic
Exception
.
- The order of catching
- Custom Exceptions
- We can raise our custom exception by inheriting from base class
Exception
. - The base
Exception
__init__()
takes a custom message. raise
is the keyword to raise the custom exception.
- We can raise our custom exception by inheriting from base class
Thoughts¶
Day 43 | Monday August 5,2019¶
Days Progress¶
- Exception is a great way to make the application more robust.
try/except
are the tools to catch exceptions.BaseException
is the base class of all exception which should never be caught in our code.Exception
is the exception class which needs to be caught.except
takes a tuple of exception.
Thoughts¶
Day 42 | Thursday August 1,2019¶
Days Progress¶
- Inheritance is the best way to share property and responsibility across the code.
- Car has 4 wheels, but Bike has only 2 wheels, but most other parts are similar.
- It creates code re-usability.
- Divides the code from more generic to specific.
- Multiple inheritance is possible, but mostly restricted to Mixins.
Thoughts¶
Day 41 | Wednesday July 31,2019¶
Days Progress¶
str()
:- On our raw object, is we use
str()
it gives a completely non-relevant information. - We can change this by overriding the
__str__()
method in our class.
- On our raw object, is we use
repr()
:- Its informs a way of creation of the object.
- We can override
__repr__
method in our class for this information.
Thoughts¶
Day 40 | Monday July 29,2019¶
Days Progress¶
isinstance()
:- returns
True
if an object is an instance of a class.
- returns
issubclass()
:- returns
True
is an object is a subclass of a class. bool
is a subclass and instance ofint
object
is the parent class of all object.
- returns
any()
:- returns
True
, if any value in the collection is True.
- returns
all()
:- returns
True
, if all the value in the collection is True.
- returns
bool
:bool
being a subclass ofint
, we have some weird combination, which we can try.True + True
: 2{0,1, True, False}
: returns{0, 1}
Thoughts¶
Day 39 | Sunday July 28,2019¶
Days Progress¶
- Class methods are unique methods, which operates on class variables.
@classmethod
: a special decorator to create a class method.- Class methods take
cls
as argument and notself
. - The instance object can access the class methods, since it is aware of their existence.
Thoughts¶
Day 38 | Saturday July 27,2019¶
Days Progress¶
- The journey into object oriented programming with python.
- Python has no protection of its class variables for modification unlike Java.
__init__(self)
- It is special function which python calls under the hood when initializing a object.
- It takes
self
by default.
Thoughts¶
Day 37 | Friday July 26,2019¶
Days Progress¶
- OOPs concept.
- Everything is an object in Python.
- Class is template, blue print of a object.
- Instance is a specific creation of a class.
- We can have both
- Class Variables
- Accessed by class.
- Instance Variable
- Accessed by instance of a class.
- Class Variables
self
is a special name given to a instance in python.
Thoughts¶
Day 36 | Thursday July 25,2019¶
Days Progress¶
.items()
on adict()
returns a list of tuples.- A list of tuples can also be converted back to a dictionary.
zip()
function combines two lists into a list of tuples.for
loop can be used to iterate over azip
function.- Using
zip()
on asymmetrical list will create a list of tuples with the least no of elements common in the list. dict(zip(list1, list2))
: converts a list of tuple back to a dictionary.
Thoughts¶
Day 35 | Wednesday July 24,2019¶
Days Progress¶
- Enhanced the learning of list slice.
- Simple index gives an element of the list.
- The slice has the following format.
[1:3]
: the index will start from 1, ends at 3 - 1 = 2- No of elements will be 3 - 1 = 2
- Slice also supports negative index.
-1
: give the last element-len(list)
: gives the first element
- Slice also has 3rd index, which is
step
.[::2]
: skips 2 elements.[::-1]
: short cut to reverse a list.
Thoughts¶
Day 34 | Tuesday July 23,2019¶
Days Progress¶
- Today is the day, when I am more confused than aware.
- There is no tuple comprehension in python, but there are Generator expressions.
- Generator expressions are created with this syntax.
(num * num for num in range(11))
- Ideally we expect it to be a tuple comprehension, but it is a generator object.
- Generator expressions are a memory efficient way of creating a big list.
- We cannot index on the generator object, gives a
TypeError
. next()
andfor/each
can be used to iterate over a generator.
Thoughts¶
- My Github Url
- References.
- Link to tweet
Day 33 | Monday July 22,2019¶
Days Progress¶
- The
set
anddict
comprehensions are very similar in syntax.set
comprehensions.{num * num for num in range(11)}
dict
comprehensions.{num: num * num for num in range(11)}
- Both
set
anddict
comprehensions are not ordered.
Thoughts¶
Day 32 | Friday July 19,2019¶
Days Progress¶
- Built-in function which works on the
list
sum()
: returns the sum of a listmin()
: returns the smallest element in the list.max()
: returns the biggest element in the list.sorted()
: returns a sorted list.reverse=True
as a default argument will reverse the list.
Thoughts¶
Day 31 | Thursday July 18,2019¶
Days Progress¶
- Continued with List comprehensions.
- We can use conditionals in list comprehension to filter values.
[num**2 for num in numbers if num %2 == 0]
- The conditional comes at the end.
- This conditional works as a filter.
- We have 3 ways to use List comprehensions.
- Map - All values are used
- Filter - Some values are used
- Map/Filter - Some values filtered and then modified.
Thoughts¶
Day 30 | Tuesday July16,2019¶
Days Progress¶
- There are various type conversion which we can use.
split()
: convert string to a list.join()
: convert a list to string.",".join(my_list)
- tuple unpacking can also be used when using
.split()
- Learned about list comprehensions.
[num**2 for num in numbers]
: list of square of numbers.- We right the square brackets first
- Followed by the
for
loop. - The variable used in the
for
loop is available to the left of loop,num
- Apply mapping on the variable left of
for
loop.
- We can combine with
tuple
andf
strings to get more valuable information.
Thoughts¶
Day 29 | Saturday July 13,2019¶
Days Progress¶
- Worked on the Github Api Project using these concepts.
requests
exceptions
APIs
- Query Parameters.
Thoughts¶
Day 28 | Friday July 12,2019¶
Days Progress¶
- learned mostly about
requests
library. - 4 HTTP methods
GET
POST
PUT
DELETE
- HTTP code
1XX
: Information2XX
: Success3XX
: Redirection4XX
: Client error5XX
: Server error
Thoughts¶
Day 27 | Thursday July 11,2019¶
Days Progress¶
__name__
is a nice way to put code when we want to execute as a script.- The above code is not invoked when called as a library.
try/except
is a great way to catch error's in code, and give alternate execution path.
Thoughts¶
Day 26 | Wednesday July 10,2019¶
Days Progress¶
- Mostly learned about python file's and debugging techniques.
Thoughts¶
Day 25 | Tuesday July 9,2019¶
Days Progress¶
while
loop is used to iterate over numbers in place of sequence.- Also when we are not sure about the no of iteration
break
:- It stops the execution of loop, and jumps to end of loop.
- If present in nested loop, it breaks the loop it is present in.
continue
:- It stops the loop execution and jump to start of the loop.
return
:- It also return the loop control to outside of the loop.
Thoughts¶
Day 24 | Friday July 5,2019¶
Days Progress¶
- Today's learning was mostly on the Control flow.
- We have different variant of
if
condition.if
if-else
if-elif-else
- We can also check truthiness.
Thoughts¶
Day 23 | Thursday July 4,2019¶
Days Progress¶
- Continuing the process of learning loop, understood about looping with
dict
- There are mainly 3 looping with
dict
.key()
- this is default, so do not have to specify infor
loop..items()
- returns a tuple of key, value pair..values()
- returns only the values indict
..enumerate(.items())
- gives, index and a tuple of key value.
Thoughts¶
Day 22 | Wednesday July 3,2019¶
Days Progress¶
- Mostly improved the understanding of loops with list and range function.
for
loops create a temporary variable which is in scope outside offor
loop.range()
is a good function for looping, it has 3 variant.range(5)
: default, creates the number from 0 to 4range(1,5)
: start and end index, creates the number from 1 to 4, 5 non inclusive.range(1,5,2)
: the 3rd argument issteps
, will step those many numbers.- It does not take any Keyword arguments.
Thoughts¶
Day 21 | Monday July 1,2019¶
Days Progress¶
- I have reached that day, where it is said, 21 days is required minimum to form a habit.
- Hope this habit stays with me.
- Learning continued on
and
,or
, andnot
operator. - It was an eye opener.
and
andor
returns the value of one of the expression and notTrue
orFalse
and
- It returns the value of 2nd operand if the first operand is
True
else value of first.
- It returns the value of 2nd operand if the first operand is
or
- It returns the value of 1st operand if it evaluates to
True
, else value of second.
- It returns the value of 1st operand if it evaluates to
not
- Returns the inverse of the operator.
Thoughts¶
Day 20 | Sunday June 30,2019¶
Days Progress¶
- Comparison operators in Python.
<
: Less than>
: greater than<=
: less than equal to>=
: greater than equal to==
: equal to!=
: Not equal tois
: Identity, when both object points to same.
- Strings are compared based on their ASCII value.
- The capital letters are smaller than small letters.
Thoughts¶
Day 19 | Friday June 28,2019¶
Days Progress¶
- What are the truthiness of various data types.
- integers:
0
isFalse
- any other number is
True
- Collections:
- Empty list, tuple, Dictionary, sets are
False
- Non Empty collections are
True
- Empty list, tuple, Dictionary, sets are
- Strings:
- Empty String is
False
- Non Empty String are
True
.
- Empty String is
None
isFalse
- integers:
Thoughts¶
Day 18 | Wednesday June 26,2019¶
Days Progress¶
- Learned about the list slice.
my_list[0:3
: Returns 0 - 2nd indexmy_list[:]
: clone the entire list.my_list[-1]
: Special way to get the last item.
Thoughts¶
Day 17 | Tuesday June 25,2019¶
Days Progress¶
- Finally crossed the last attempts days.
- Learned about mutability.
- Basic data type are immutable.
int
,float
,decimal
,str
,bool
- Containers data type are divided
list
,set
,dict
are mutabletuple
is immutable.
Thoughts¶
Day 16 | Monday June 24,2019¶
Days Progress¶
- Adding/Accessing dictionary elements.
- add new key/Value pair.
nums["four"] = 4
- There are no duplicate key in Dictionaries.
- If new value is assigned to same key, it will override the old value.
- Existence of a key in Dictionaries.
"one" in nums
.update()
: Combine two list.- 3 important functions on Dictionaries
.keys()
: returns special list called dict keys.values()
: returns a special list called dict values.item()
: returns a list of tuple, called dict items
- add new key/Value pair.
Thoughts¶
Day 15 | Sunday June 23,2019¶
Days Progress¶
- Started learning about dictionaries.
- Dictionaries store
key:value
pair. - Dictionaries are mutable but the
keys
are immutable. - The search is very fast, just like
sets
. - Retrieve the value with index as the
key
a["one"]
get()
method can be used when we do not want an error while retrieving a value.- Its returns a default value if the key is not present.
Thoughts¶
Day 14 | Saturday June 22,2019¶
Days Progress¶
- Important set operation.
union()
or|
: Returns the union of two sets.intersection()
or&
: Returns the intersection of two sets.difference()
or-
: present in 1 set but not in other.
Thoughts¶
Day 13 | Thursday June 20,2019¶
Days Progress¶
- Updated my RAM with set operation for CRUD.
add()
- Adds item to the set.discard()
- Removes item from the set, if not present, gives no error.remove()
- Removes item from the set, if not present. givesKeyError
.update()
- Adds item from a sequence into a set.
Thoughts¶
Day 12 | Wednesday June 19,2019¶
Days Progress¶
- Understood the basic premise around sets.
- Empty sets can only be created using
set()
function, empty{}
creates a dict. - Sets stores only immutable data type which can give a
hash()
value.a = {"a", (1, 2, 3), [1, 2, 3]}
# TypeError: unhashable type: 'list'
- Sets are used to remove duplicates from List.
- Sets searching is very fast.
- Sets do not have a indexing order.
- Empty sets can only be created using
Thoughts¶
Day 11 | Tuesday June 18,2019¶
Days Progress¶
- Explored the different ways to create a
tuple
- Create a empty tuple.
a = tuple()
b = ()
- Create a single item tuple.
a = (1,)
and nota = (1)
- Brackets are not mandatory for tuple.
b = 1, 2, 3, 4, 5
- indexing in tuple, same as list.
b[0]
- Create a empty tuple.
Thoughts¶
Day 10 | Monday June 17,2019¶
Days Progress¶
- Established some basic understanding on list operations
- Operations to add item to the list.
append()
: add an item to end of the list.insert(2, "bbbb")
: insert at an index.extend()
: concatenates two list.
- Operation on list look-up, which is very slow, almost linear.
index(value)
: returns first index of valueValueError:
if the value is not present in list.
count(value)
: returns the no of times a value is present.- return's
0
is the value is not present.
- return's
- Operation to remove item from list.
remove(value)
: removes the value from the list, if not present does not throw error.pop()
: remove and returns the last element of the list or the index.
- List are heterogeneous.
Thoughts¶
Day 09 | Sunday June 16,2019¶
Days Progress¶
- Understood the list's sort and the built-in sorted function.
sorted()
returns a listlist.sort()
orlist.reverse()
returnsNone
Thoughts¶
Day 08 | Saturday June 15,2019¶
Days Progress¶
- Started after a gap of 1 cheat day.
- List was the focus today.
- list can be created using
[]
orlist()
- list is a ordered collection.
- list is a heterogeneous collection.
- list elements can be accessed using index start at
0
- list can be created using
- List has 1 efficient way of declaring.
names = [
"XXX",
"YYY",
"ZZZ", # unlike json, we can have comma at the last element,
# it helps with git diff
]
Thoughts¶
Day 07 | Thursday June 13,2019¶
Days Progress¶
- Function scope is little confusing without practice.
- There is a global scope and a local scope to a function.
- If same variable name is same, local scope gets preference.
- Global variable cannot be modified even thought it share the same name.
- This code will work.
- But this code will not work, gives
UnboundLocalError:
. - The explanation is mentioned in the Python Documentation.
Thoughts¶
Day 06 | Wednesday June 12,2019¶
Days Progress¶
- List or any other mutable data type should not be used as the default arguments.
- The list is initialized when the function is called the 1st time, and then it modifies the same list.
Thoughts¶
Day 5 | Tuesday June 11,2019¶
Days Progress¶
- Started with the Function's Arguments.
- Positional arguments must be passed to functions.
- Default arguments are always provide at the end of function's argument list.
- We can give none, one, all arguments to a function with only default arguments list.
- Labeled arguments can be passed in any order to a function.
Thoughts¶
Day 04 | Monday June 10,2019¶
Days Progress¶
- Started the
functions
section of the lecture. - This lesson, teaches about different function type.
- Function with no arguments and no return type
- Function with no arguments and a return type
- Function with 2 arguments and a return type
- Function with multi-line function body.
- return is always optional in function, it returns
<class 'NoneType'>
Thoughts¶
- The function returning
<class 'NoneType'>
was a eye opener. - My Github Url
- Link to tweet
Day 03 | Sunday June 9,2019¶
Days Progress¶
- Completed the Data Type chapter in the FrontEnd Master's Python fundamentals.
- This chapter introduces some nice concept about data types
45j
is a complex data type<class 'complex'>
but not45i
, soj
is the identifier for complex number.new_name f"Hello, {name}"
is a format string,name
in{}
is the variable name which will be replaced.- Same variable can be used to store number, or strings.
- String can be created by both
'string 1 '
or" String 2 "
- Integer division gives the result in floating point
3/2 = 1.5
Thoughts¶
- Python Data types have lot of power inside them with very less ambiguity.
- My Github Url
- Link to tweet
Day 02 | Saturday June 8,2019¶
Days Progress¶
- Understood the VSCode basic settings, got help from a great tutorial by Corey Schafer
- The tutorials talks about these topics
- Change the way settings is displayed as JSON, in place of UI.
- Select virtual environment.
- Change color theme.
- Change file icons.
- Set the global python path -
"python.pythonPath": "<Path>"
- Set a global python file formatter, we are using Black for this.
"python.formatting.provider": "black",
- Also change the option to run the formatter on saving the file.
"editor.formatOnSave": true,
- Also change the option to run the formatter on saving the file.
- Enable Linting.
- Git Integration.
- Unit Testing.
Thoughts¶
- VScode has lot of power, lets see how much I learn from it.
- My Github Url
- Link to tweet
Day 01 | Friday June 7,2019¶
Days Progress¶
- Started the Python Fundamentals course by Nina Zakharenko.
- Today's main focus was setting my these things.
- Virtual environment.
- VScode setup.
- Faced few issues, which stackoverflow helped in solving
Issues and Solutions¶
- There was no activate script when the virtual environment was created by using the command
python -m venv .env
- On doing Google for the problem found that running the same command again solves the issue, so ran
python -m venv env
again and viola the activate script appeared.
- On doing Google for the problem found that running the same command again solves the issue, so ran
- VScode was not recognizing the virtual environment created inside a sub folder in the project.
- Deleted the pre-existing environment and created a new virtual environment at the project root.
Thoughts¶
- Programming is just efficient Google technique.
- My Github Url
- Link to tweet
Reference¶
- QuoteFancy | Image Source
- 100DaysOfCode Official Website
- Learn Python Track from Team TreeHouse
- MIT 6.00SC Introduction to Computer Science and Programming
- Create a Tweet With image Preview for Free
- FrontEndMasters | Python Fundamentals | Nina Zakharenko
- Corey Schafer