diff --git a/.gitattributes b/.gitattributes index bdb0cabc..cee6d0d8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ -# Auto detect text files and perform LF normalization +# Auto detect the text files and perform LF normalization easily! * text=auto -# Custom for Visual Studio +# Custom for Visual Studio (Any Version) *.cs diff=csharp # Standard to msysgit diff --git a/BinaryToDecimal.py b/BinaryToDecimal.py index ac41308d..1c3096c8 100644 --- a/BinaryToDecimal.py +++ b/BinaryToDecimal.py @@ -1,25 +1,25 @@ # Python: Binary to Decimal Conversion # binToDec and decToBin functions are rendered obsolete by the universal convert function -def binToDec(binNum): +def binToDec(binNum): #function created to convert binary to decimal with parametere binNum decNum = 0 power = 0 - while binNum > 0: - decNum += 2 ** power * (binNum % 10) - binNum //= 10 - power += 1 + while binNum > 0: #loop will run till binNum is greater than 0 + decNum += 2 ** power * (binNum % 10) + binNum //= 10 # reducing binNum everytime by 1 digit + power += 1 # increasing power by 1 each loop return decNum -def decToBin(decNum): +def decToBin(decNum): #function created to convert decimal to binary with parametere decNum binNum = 0 power = 0 - while decNum > 0: + while decNum > 0:#loop will run till decNum is greater than 0 binNum += 10 ** power * (decNum % 2) - decNum //= 2 - power += 1 + decNum //= 2 # reducing decNum everytime by 1 digit + power += 1 # increasing power by 1 each loop return binNum -def convert(fromNum, fromBase, toBase): +def convert(fromNum, fromBase, toBase): #function for converting from any base to any other base toNum = 0 power = 0 while fromNum > 0: @@ -31,4 +31,4 @@ def convert(fromNum, fromBase, toBase): # print (str(binToDec(101011))) # print (str(decToBin(128))) print (str(convert(127, 10, 8))) # converts 127 in base 10 to base 8 -print (str(convert(101001, 2, 2))) \ No newline at end of file +print (str(convert(101001, 2, 2))) diff --git a/Contributing.txt b/Contributing.txt new file mode 100644 index 00000000..52d1fd31 --- /dev/null +++ b/Contributing.txt @@ -0,0 +1,21 @@ +Contributions are always welcome!!!! +If you want to contribute to this repository follow the below procedure - +1. Fork this repository +2. Clone the code to your local system and go through readme.md +3. You can create another branch to add further commits + +GIT COMMANDS FOR CONTRIBUTING - +1. To clone this repository +`git clone [code link]` +2.To create new branch +`git checkout -b [branch name] ` +3. To stage files +`git add .` +4.To commit changes +`git commit -m "commit message"` +5. To push changes +`git push [remote branch] [new branch]` + +HAPPY CONTRIBUTION!!!!!!!! + + \ No newline at end of file diff --git a/Date Time Timestamp/Date_Time_Timestamp.py b/Date Time Timestamp/Date_Time_Timestamp.py index 7897332c..cc533dcf 100644 --- a/Date Time Timestamp/Date_Time_Timestamp.py +++ b/Date Time Timestamp/Date_Time_Timestamp.py @@ -19,21 +19,21 @@ # get day of the week using date.weekday() # Monday is 0 from datetime import date -d1 = date.today() -print(d1) -print(d1.month, d1.day, d1.year) -print(d1.weekday()) +todays_date = date.today() +print(todays_date) +print(todays_date.month, todays_date.day, todays_date.year) +print(todays_date.weekday()) # ISO format is a string format, yyyy-mm-dd # --------------------------- # date_object.isoformat() does the same thing as str(date_object) from datetime import date -d1 = date.fromisoformat('2011-11-23') -print(d1) -print(str(d1)) -print(d1.isoformat()) -d1 +todays_date = date.fromisoformat('2011-11-23') +print(todays_date) +print(str(todays_date)) +print(todays_date.isoformat()) +todays_date # Comparison, addition and sutraction of dates # --------------------------- @@ -42,10 +42,10 @@ # The same comparison and add/subtract operations can be used with time objects. from datetime import date -d1 = date.today() +todays_date = date.today() d2 = date(2015, 5, 14) -print(d1 > d2) -print(d1 - d2) +print(todays_date > d2) +print(todays_date - d2) # Time # --------------------------- @@ -95,9 +95,9 @@ # A timedelta can also be multiplied or divided by an integer or float from datetime import timedelta, date, time -d1 = date(2011, 6, 15) +todays_date = date(2011, 6, 15) d2 = date(2012, 9, 18) -td = d2 - d1 +td = d2 - todays_date print(td, type(td)) print(td.total_seconds()) print(td * 3) @@ -130,4 +130,4 @@ start_time = time.process_time() # do some stuff end_time = time.process_time() -print('operation executed in ', end_time - start_time) \ No newline at end of file +print('operation executed in ', end_time - start_time) diff --git a/Intro to Python Data Structures/Some Basic Terminologies in Python Data Structure b/Intro to Python Data Structures/Some Basic Terminologies in Python Data Structure new file mode 100644 index 00000000..754c07a5 --- /dev/null +++ b/Intro to Python Data Structures/Some Basic Terminologies in Python Data Structure @@ -0,0 +1,31 @@ +##Data Structure Overview +Data structures are fundamental concepts of computer science which helps is writing efficient programs in any language. Python is a high-level, interpreted, interactive and object-oriented scripting language using which we can study the fundamentals of data structure in a simpler way as compared to other programming languages. + +In this chapter we are going to study a short overview of some frequently used data structures in general and how they are related to some specific python data types. There are also some data structures specific to python which is listed as another category. + +##General Data Structures +The various data structures in computer science are divided broadly into two categories shown below. We will discuss about each of the below data structures in detail in subsequent chapters. + +#Liner Data Structures +These are the data structures which store the data elements in a sequential manner. + +Array: It is a sequential arrangement of data elements paired with the index of the data element. +Linked List: Each data element contains a link to another element along with the data present in it. +Stack: It is a data structure which follows only to specific order of operation. LIFO(last in First Out) or FILO(First in Last Out). +Queue: It is similar to Stack but the order of operation is only FIFO(First In First Out). +Matrix: It is two dimensional data structure in which the data element is referred by a pair of indices. + +#Non-Liner Data Structures +These are the data structures in which there is no sequential linking of data elements. Any pair or group of data elements can be linked to each other and can be accessed without a strict sequence. + +Binary Tree: It is a data structure where each data element can be connected to maximum two other data elements and it starts with a root node. +Heap: It is a special case of Tree data structure where the data in the parent node is either strictly greater than/ equal to the child nodes or strictly less than it’s child nodes. +Hash Table: It is a data structure which is made of arrays associated with each other using a hash function. It retrieves values using keys rather than index from a data element. +Graph: .It is an arrangement of vertices and nodes where some of the nodes are connected to each other through links. + +#Python Specific Data Structures +These data structures are specific to python language and they give greater flexibility in storing different types of data and faster processing in python environment. + +List: It is similar to array with the exception that the data elements can be of different data types. You can have both numeric and string data in a python list. +Tuple: Tuples are similar to lists but they are immutable which means the values in a tuple cannot be modified they can only be read. +Dictionary: The dictionary contains Key-value pairs as its data elements. diff --git a/Iris Dataset/Iris_Dataset.ipynb b/Iris Dataset/Iris_Dataset.ipynb new file mode 100644 index 00000000..398f454e --- /dev/null +++ b/Iris Dataset/Iris_Dataset.ipynb @@ -0,0 +1,1174 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Data Science\n", + "### Exploring the Iris Dataset" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import pandas as pd\n", + "import matplotlib.pyplot as plt" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Load Data\n", + "Load the data from CSV file into a Pandas dataframe, and print the top few rows." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + " | id | \n", + "sepal_length | \n", + "sepal_width | \n", + "petal_length | \n", + "petal_width | \n", + "species | \n", + "
---|---|---|---|---|---|---|
0 | \n", + "0 | \n", + "5.1 | \n", + "3.5 | \n", + "1.4 | \n", + "0.2 | \n", + "Iris-setosa | \n", + "
1 | \n", + "1 | \n", + "4.9 | \n", + "3.0 | \n", + "1.4 | \n", + "0.2 | \n", + "Iris-setosa | \n", + "
2 | \n", + "2 | \n", + "4.7 | \n", + "3.2 | \n", + "1.3 | \n", + "0.2 | \n", + "Iris-setosa | \n", + "
3 | \n", + "3 | \n", + "4.6 | \n", + "3.1 | \n", + "1.5 | \n", + "0.2 | \n", + "Iris-setosa | \n", + "
4 | \n", + "4 | \n", + "5.0 | \n", + "3.6 | \n", + "1.4 | \n", + "0.2 | \n", + "Iris-setosa | \n", + "
\n", + " | 0 | \n", + "1 | \n", + "2 | \n", + "3 | \n", + "species | \n", + "
---|---|---|---|---|---|
0 | \n", + "5.1 | \n", + "3.5 | \n", + "1.4 | \n", + "0.2 | \n", + "Iris-setosa | \n", + "
50 | \n", + "7.0 | \n", + "3.2 | \n", + "4.7 | \n", + "1.4 | \n", + "Iris-versicolor | \n", + "
100 | \n", + "6.3 | \n", + "3.3 | \n", + "6.0 | \n", + "2.5 | \n", + "Iris-virginica | \n", + "
\n", + " | 0 | \n", + "1 | \n", + "2 | \n", + "3 | \n", + "
---|---|---|---|---|
count | \n", + "150.000000 | \n", + "150.000000 | \n", + "150.000000 | \n", + "150.000000 | \n", + "
mean | \n", + "5.843333 | \n", + "3.054000 | \n", + "3.758667 | \n", + "1.198667 | \n", + "
std | \n", + "0.828066 | \n", + "0.433594 | \n", + "1.764420 | \n", + "0.763161 | \n", + "
min | \n", + "4.300000 | \n", + "2.000000 | \n", + "1.000000 | \n", + "0.100000 | \n", + "
25% | \n", + "5.100000 | \n", + "2.800000 | \n", + "1.600000 | \n", + "0.300000 | \n", + "
50% | \n", + "5.800000 | \n", + "3.000000 | \n", + "4.350000 | \n", + "1.300000 | \n", + "
75% | \n", + "6.400000 | \n", + "3.300000 | \n", + "5.100000 | \n", + "1.800000 | \n", + "
max | \n", + "7.900000 | \n", + "4.400000 | \n", + "6.900000 | \n", + "2.500000 | \n", + "