Skip to content

Commit 263e612

Browse files
committed
Add comments to files
1 parent 19b7467 commit 263e612

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Diff for: passgen.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import random
22
import string
33

4+
5+
#Setting Variables to store alphabets, numbers and symbols.
46
up_letters = string.ascii_uppercase
57
low_letters = string.ascii_lowercase
68
numbers = string.digits
79
symbols = "!@#$%^&*()_}{|<>?"
810

11+
12+
#Setting variable to hold all characters in a pool.
913
pool = up_letters + low_letters + numbers + symbols
1014

15+
#Ask user how many characters to use, set it to a variable.
1116
n = input("Enter number of chars: ")
1217

18+
#Create function that generates password using using random.
1319
def gen(n):
14-
print "".join(random.sample(pool, n))
20+
print "".join(random.sample(pool, n)) #random.sample takes a second argument specifies how many items to sample.
1521

22+
#Call the function.
1623
gen(n)

Diff for: scrabble_score.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
2+
#Define a dictionary that holds the value in integers of each letter.
13
score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2,
24
"f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3,
35
"l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1,
46
"r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4,
57
"x": 8, "z": 10}
68

7-
9+
#Create function that gives score
810
def scrabble_score(word):
911
total = 0
10-
for i in word:
11-
total += score[i.lower()]
12+
for i in word: #for loop iterates through each character in word.
13+
total += score[i.lower()] #Adds the value of each character to word.
1214
return total
15+
16+
#Call and display the function.
17+
print scrabble_score("ridiculous")

0 commit comments

Comments
 (0)