Skip to content

[Clàudia Pintos] lab-functions#12

Open
claudiarelat wants to merge 1 commit intoIronhack-data-bcn-oct-2023:mainfrom
claudiarelat:main
Open

[Clàudia Pintos] lab-functions#12
claudiarelat wants to merge 1 commit intoIronhack-data-bcn-oct-2023:mainfrom
claudiarelat:main

Conversation

@claudiarelat
Copy link
Copy Markdown

No description provided.

@sh-ih
Copy link
Copy Markdown

sh-ih commented Oct 13, 2023

Clàudia,
Great job on this lab!

Some comments:

On question 2, your function passes the test but there is a case where setting largest=0 would create some issues: when your array has only negative numbers. If you run: greatest([-1,-5,-800]) you’ll get 0 as result, instead of -1.
A way to deal with this cases is to set largest=+inf. In Python, +inf is an unbounded upper value.
Another option would be to set largest=arr[0]

On question 5, you could simplify your code by calling the functions you created on the previous two questions:

def oper_all(arr, oper):
    if oper == "+":
        return sum_all(arr)
    elif oper == "*":
        return mult_all(arr)

I really liked how you named your variables with pretty clear names. That helps a lot when other people (or future you!) uses your code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants