diff --git a/__pycache__/test.cpython-36.pyc b/__pycache__/test.cpython-36.pyc new file mode 100644 index 0000000..c2810e4 Binary files /dev/null and b/__pycache__/test.cpython-36.pyc differ diff --git a/test.py b/test.py index 7c0ef3c..a0f04df 100644 --- a/test.py +++ b/test.py @@ -13,19 +13,25 @@ def fizz_buzz(self, digit_1, digit_2): for i in range(1, 100): if i % digit_1 == 0: if i % digit_2 == 0: - print 'fizzbuzz!' + print ('fizzbuzz!') else: - print 'fizz!' + print ('fizz!') elif i % digit_2 == 0: - print 'buzz!' + print ('buzz!') else: - print i + print (i) - def json_to_csv(self, json_file_path, outfile_path): - """Convert a file containing a list of flat JSON objects to a csv. - - What's a DictWriter, you say? Never heard of it! + def bubble_sort(self, alist): + length = len(alist) - 1 + for i in range(0, length): + if alist[i] > alist[i + 1]: + # alist[i], alist[i+1] = alist[i+1], alist[i] # python way + temp = alist[i] + alist[i] = alist[i + 1] + alist[i + 1] = temp + def json_to_csv(self, json_file_path, outfile_path): + """DictWriter has saved my life!!! """ with open(json_file_path) as f: data = json.load(f) @@ -34,3 +40,7 @@ def json_to_csv(self, json_file_path, outfile_path): writer.writerow(data[0].keys()) for item in data: writer.writerow(item.values()) + +if __name__ == '__main__': + t = TestClass(1, 2, 3) + t.fizz_buzz(3, 5) \ No newline at end of file