Skip to content

Commit a4cfe1c

Browse files
Merge pull request geekcomputers#633 from ishitagupta8720/master
Added comments
2 parents 7d51150 + e99d2b3 commit a4cfe1c

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

Binary_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
def binarySearch(arr, l, r, x):
44
while l <= r:
55

6-
mid = l + (r - l) / 2; #extracting the middle element of the array
6+
mid = l + (r - l) / 2; #extracting the middle element from the array
77

88
# Check if x is present at mid
99
if arr[mid] == x:

CountMillionCharacter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@
304304
except:
305305
continue
306306

307-
wordfreq = [wordlist.count(w) for w in wordlist] #counts frequency of a letter in the list
307+
wordfreq = [wordlist.count(w) for w in wordlist] #counts frequency of a letter in the given list
308308

309309
print("String\n {} \n".format(wordstring))
310310
print("List\n {} \n".format(str(wordlist)))

Palindrome_Checker.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,28 @@
22
# DESCRIPTION: A simple script which checks if a given phrase is a Palindrome
33
# PALINDROME: A word, phrase, or sequence that reads the same backward as forward
44

5-
samplePhrase = "A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal-Panama!"
5+
samplePhrase = "A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal-Panama!"
66
# givenPhrase = ""
77
# phrase = ""
88

9-
givenPhrase = input("\nPlease input a phrase:(Press ENTER to use the sample phrase) ")
9+
givenPhrase = input("\nPlease input a phrase:(Press ENTER to use the sample phrase) ") #takes a phrase for input
1010

11+
#if nothing in given as input then the sample phrase is stored in the variable phrase otherwise the given phrase if stored
1112
if givenPhrase == "":
1213
print("\nThe sample phrase is: {0}".format(samplePhrase))
13-
phrase = samplePhrase
14+
phrase = samplePhrase
1415
else:
1516
phrase = givenPhrase
1617

17-
phrase = phrase.lower()
18+
phrase = phrase.lower() #converting all the characters of the phrase to the lowercase
1819

19-
length_ = len(phrase)
20+
length_ = len(phrase) #returns the length of string
2021
bol_ = True
2122

2223
# check using two pointers, one at beginning
2324
# other at the end. Use only half of the list.
2425
for items in range(length_ // 2):
25-
if phrase[items] != phrase[length_ - 1 - items]:
26+
if phrase[items] != phrase[length_ - 1 - items]:
2627
print("\nSorry, The given phrase is not a Palindrome.")
2728
bol_ = False
2829
break

ReadFromCSV.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
__author__ = 'vamsi'
2-
import pandas as pd
3-
from matplotlib import pyplot as plt
2+
import pandas as pd #pandas library to read csv file
3+
from matplotlib import pyplot as plt #matplotlib library to visualise the data
44
from matplotlib import style
55

66
style.use("ggplot")
77

88
"""reading data from SalesData.csv file
99
and passing data to dataframe"""
1010

11-
df = pd.read_csv("C:\\Users\Test\Desktop\SalesData.csv")
12-
x = df["SalesID"].as_matrix() # casting SalesID to list
11+
df = pd.read_csv("C:\\Users\Test\Desktop\SalesData.csv") #Reading the csv file
12+
x = df["SalesID"].as_matrix() # casting SalesID to list #extracting the column with name SalesID
1313
y = df["ProductPrice"].as_matrix() # casting ProductPrice to list
1414
plt.xlabel("SalesID") # assigning X-axis label
1515
plt.ylabel("ProductPrice") # assigning Y-axis label

0 commit comments

Comments
 (0)