Skip to content

Commit

Permalink
PEP8 Flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bluszcz committed Oct 2, 2018
1 parent b300b4c commit 7304bf0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
4 changes: 2 additions & 2 deletions chaos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def main():
print ("This program illustrates a chaotic function")
print("This program illustrates a chaotic function")

while True:
try:
Expand All @@ -16,7 +16,7 @@ def main():

for i in range(10):
x = 3.9 * x * (1-x)
print (x)
print(x)


if __name__ == '__main__':
Expand Down
20 changes: 12 additions & 8 deletions dice.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
# Script Name : dice.py
# Author : Craig Richards
# Created : 05th February 2017
# Last Modified :
# Last Modified :
# Version : 1.0

# Modifications :

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

import random


class Die(object):
# A dice has a feature of number about how many sides it has when it's established,like 6.
# A dice has a feature of number about how many sides it has when it's
# established,like 6.
def __init__(self):
self.sides = 6

"""because a dice contains at least 4 planes.
So use this method to give it a judgement when you need to change the instance attributes."""
So use this method to give it a judgement when you need
to change the instance attributes.
"""
def set_sides(self, sides_change):
if sides_change >= 4:
if sides_change != 6:
print("change sides from 6 to ", sides_change, " !")
else: # added else clause for printing a message that sides set to 6
print ("sides set to 6")
else:
# added else clause for printing a message that sides set to 6
print("sides set to 6")
self.sides = sides_change
else:
print("wrong sides! sides set to 6")
Expand All @@ -37,4 +41,4 @@ def roll(self):
d1 = Die()
d.set_sides(4)
d1.set_sides(4)
print (d.roll(), d1.roll())
print(d.roll(), d1.roll())
23 changes: 13 additions & 10 deletions two_num.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Author Anurag Kumar (mailto:[email protected])
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Given an array of integers, return indices of the two numbers
such that they add up to a specific target.
You may assume that each input would have exactly one solution,
and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Expand All @@ -10,14 +12,15 @@
"""


def twoSum(nums, target):
chk_map = {}
for index, val in enumerate(nums):
compl = target - val
if compl in chk_map:
indices = [chk_map[compl], index]
print(indices)
return [indices]
else:
chk_map[val] = index
return False
compl = target - val
if compl in chk_map:
indices = [chk_map[compl], index]
print(indices)
return [indices]
else:
chk_map[val] = index
return False

0 comments on commit 7304bf0

Please sign in to comment.