Skip to content

Commit 7304bf0

Browse files
committed
PEP8 Flake8 fixes
1 parent b300b4c commit 7304bf0

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

chaos.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
def main():
5-
print ("This program illustrates a chaotic function")
5+
print("This program illustrates a chaotic function")
66

77
while True:
88
try:
@@ -16,7 +16,7 @@ def main():
1616

1717
for i in range(10):
1818
x = 3.9 * x * (1-x)
19-
print (x)
19+
print(x)
2020

2121

2222
if __name__ == '__main__':

dice.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
# Script Name : dice.py
22
# Author : Craig Richards
33
# Created : 05th February 2017
4-
# Last Modified :
4+
# Last Modified :
55
# Version : 1.0
66

77
# Modifications :
88

9-
# Description : This will randomly select two numbers, like throwing dice,
10-
# you can change the sides of the dice if you wish
9+
# Description : This will randomly select two numbers,
10+
# like throwing dice, you can change the sides of the dice if you wish
1111

1212
import random
1313

1414

1515
class Die(object):
16-
# A dice has a feature of number about how many sides it has when it's established,like 6.
16+
# A dice has a feature of number about how many sides it has when it's
17+
# established,like 6.
1718
def __init__(self):
1819
self.sides = 6
1920

2021
"""because a dice contains at least 4 planes.
21-
So use this method to give it a judgement when you need to change the instance attributes."""
22+
So use this method to give it a judgement when you need
23+
to change the instance attributes.
24+
"""
2225
def set_sides(self, sides_change):
2326
if sides_change >= 4:
2427
if sides_change != 6:
2528
print("change sides from 6 to ", sides_change, " !")
26-
else: # added else clause for printing a message that sides set to 6
27-
print ("sides set to 6")
29+
else:
30+
# added else clause for printing a message that sides set to 6
31+
print("sides set to 6")
2832
self.sides = sides_change
2933
else:
3034
print("wrong sides! sides set to 6")
@@ -37,4 +41,4 @@ def roll(self):
3741
d1 = Die()
3842
d.set_sides(4)
3943
d1.set_sides(4)
40-
print (d.roll(), d1.roll())
44+
print(d.roll(), d1.roll())

two_num.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""Author Anurag Kumar (mailto:[email protected])
22
3-
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
4-
You may assume that each input would have exactly one solution, and you may not use the same element twice.
3+
Given an array of integers, return indices of the two numbers
4+
such that they add up to a specific target.
5+
You may assume that each input would have exactly one solution,
6+
and you may not use the same element twice.
57
68
Example:
79
Given nums = [2, 7, 11, 15], target = 9,
@@ -10,14 +12,15 @@
1012
1113
"""
1214

15+
1316
def twoSum(nums, target):
1417
chk_map = {}
1518
for index, val in enumerate(nums):
16-
compl = target - val
17-
if compl in chk_map:
18-
indices = [chk_map[compl], index]
19-
print(indices)
20-
return [indices]
21-
else:
22-
chk_map[val] = index
23-
return False
19+
compl = target - val
20+
if compl in chk_map:
21+
indices = [chk_map[compl], index]
22+
print(indices)
23+
return [indices]
24+
else:
25+
chk_map[val] = index
26+
return False

0 commit comments

Comments
 (0)