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
6 changes: 5 additions & 1 deletion Python/random_ints.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import random

def random_ints():
# Your code here!
lst = []
while True:
lst.append(random.randint(1,10))
if lst[-1] == 6:
return lst


def test():
Expand Down
10 changes: 8 additions & 2 deletions Python/rm_smallest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
def rm_smallest(d):
# Your code here!
return 0;
if not d:
return d
else:
min_value = min(d.values())
min_key = [k for k, v in d.items() if v == min_value][0]
d.pop(min_key)
return d


def test():
assert 'a' in rm_smallest({'a':1,'b':-10}).keys()
Expand Down
6 changes: 4 additions & 2 deletions Python/square_root.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import math

def square_root(n):
# Your code here!
return -1;
try:
return math.sqrt(n)
except:
return -1

def test():
assert square_root(4) == 2
Expand Down
6 changes: 4 additions & 2 deletions Python/sum.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
def sum(lst, n):
# Your code here!
return False
count = 0
for x in lst:
count += x
return count == n

def test():
assert sum([-1, 1], 0)
Expand Down