Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mei Tze - assignment2 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
7 changes: 5 additions & 2 deletions create_box/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def create_box(height, width, character):
pass

for i in character:
return str(i * width +'\n') * height

# Tests:

Expand Down Expand Up @@ -29,3 +29,6 @@ def test_second_box():
assert create_box(1, 1, '@') == second_box_expected

# Write your own test using the `third_box_expected` box

def test_third_box():
assert create_box(3, 24, 'x') == third_box_expected
6 changes: 5 additions & 1 deletion highest_number_cubed/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
def highest_number_cubed(limit):
pass
result = []
for i in range(1, limit):
if (i **3 < limit):
result.append(i)
return result.pop()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of .pop :D

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I have just learnt that Jessica is using something like "result[-1]". It's nice too!



def test_three():
Expand Down
12 changes: 10 additions & 2 deletions list_of_prime_numbers/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@

def _is_prime(number):
pass
for i in range(2, number):
if (number % i) == 0:
return False
return True


def list_of_prime_numbers(max_number):
pass
result = []
a = max_number + 1
for i in range(2, a):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can actually try to make this shorter by writing it like this:
for i in range(2, max_number + 1)
and taking out line 11 :D that way, you don't need to create a variable.

if _is_prime(i):
result.append(i)
return result

# =================== #
# ====== Tests ====== #
Expand Down