Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ming/python/1_hello_world/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/python3
#
# https://www.hackerrank.com/challenges/py-hello-world/problem
# print "Hello, World!" to stdout


if __name__ == '__main__':
print("")
10 changes: 10 additions & 0 deletions ming/python/2_if_else/if_else.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/python3
#
# https://www.hackerrank.com/challenges/py-if-else/problem
# Given a positive integer n where 1 <= n <= 100
# If n is even and in the inclusive range of 6 to 20, print "Weird"
# If n is even and greater than 20, print "Not Weird"


if __name__ == '__main__':
n = int(input().strip())
14 changes: 14 additions & 0 deletions ming/python/3_arithmetic_operators/arithmetic_operators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/python3
#
# https://www.hackerrank.com/challenges/python-arithmetic-operators/problem
#
# Read two integers from STDIN and print three lines where:
#
# The first line contains the sum of the two numbers.
# The second line contains the difference of the two numbers (first - second).
# The third line contains the product of the two numbers.


if __name__ == '__main__':
a = int(input())
b = int(input())
28 changes: 28 additions & 0 deletions ming/python/4_loops/loops.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/python3
#
# https://www.hackerrank.com/challenges/python-loops/problem
#
# For all non-negative integers i < n, print i^2.
#
# Sample Input:
# 5
#
# Sample Output:
# 0
# 1
# 4
# 9
# 16

def looping(num):
for i in range(num):
print(square(i))


def square(num):
return num**2


if __name__ == '__main__':
n = int(input())
looping(n)
31 changes: 31 additions & 0 deletions ming/python/4_loops/loops_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/python3

import unittest

from loops import square


class TestSquare(unittest.TestCase):

def square_base_test(self, num, expected_outcome):
result = square(num)
self.assertEqual(result, expected_outcome)

def test_negative_num(self):
self.square_base_test(-1, 1)

def test_zero(self):
self.square_base_test(0, 0)

def test_one(self):
self.square_base_test(1, 1)

def test_five(self):
self.square_base_test(5, 25)

def test_ten(self):
self.square_base_test(10, 100)


if __name__ == '__main__':
unittest.main()