Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • 639336?v=3

    Fixed :)

  • 639336?v=3

    This is known compatibility issue with the new runner we launched recently. https://github.com/Codewars/codewars.com/wiki/List-of-Affected-Kata

    I'll see if I can fix this soon.

  • Profile pic
    Traceback (most recent call last):
      File "main.py", line 15, in <module>
        strexp = __randexp__(Nfact)
    NameError: name '__randexp__' is not defined

    Fails on the last test with this message.

  • 24621490?v=4

    hi, can someone explain me why -->should equal '3.58000e+01'<--
    is the correct form?? i mean this is 358 so it cant be e+01 it is e+02 , no?

  • 7484300?v=3

    No problem, just trying to help out.

    I get the automatic PEP8 warnings in my editor using PyCharm (amongst other warnings) and it's kind of a game for me to try to write my code the first time without any warnings!

  • Profile pic

    Sure, good point.
    Thank you again

  • 7484300?v=3

    I don't think it's an official Codewars policy (I can't speak for them, I'm just a regular user) that all Python katas must abide by PEP8. But not only does it help to keep the Python katas consistent across the site, it can also help beginners to learn the correct way, the first time. Habits can be hard to break!

    There is a nice guideline written by @bkaes (ranked #8 overall) you could check out here:


    2.3 Follow your language's naming conventions

    Every language has its quirks. Some of them get discussed in the later sections. However, there's one thing that should get mentioned at this point: make sure to use your language's proposed naming convention, if there exists one.

    This includes simple character cases like capitalized class names (almost all object oriented languages) or method names (CSharp), and whether a multi word function should be written with underscores (also called snake_case, e.g. my_awesome_function, Ruby, Python) or in camelCase (Haskell, JavaScript CoffeeScript).


  • Profile pic

    Thanks for checking.
    The way the kata is now could appear a bit "strange".
    But it is easy to imagin situation where the request of the number format make sense.
    Just think to a function that has to print out the results.
    In that case is fair enougth to print readable numbers with predefined accurancy.

  • Profile pic

    Thanks for your welcome and for offering your help.
    Actually, the random tests are given by a random generator of expressions.
    So, it is easy to increase the number of test. Unless you have something else in mind.
    How many tests you think should be there?

  • Profile pic

    Thank you for your suggestion.
    I included it, and made further refinements in the description.

  • Profile pic

    Thanks for your comments.
    I changed the kata accordingly.
    Anyway, I see you refer to Python PEP8 Style Guide for Python Code.
    Is there an official regulament of codewars which state that the
    katas in python must strictly follow that style?

  • 7484300?v=3

    Python PEP8:

    Function Naming Conventions

    Function names should be lowercase, with words separated by underscores as necessary to improve readability.

    mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards compatibility.

    Variable names:

    Use the function naming rules: lowercase with words separated by underscores as necessary to improve readability.


    def sum_prod(str_expression):
  • Profile pic

    Nice solution without eval hacks.

  • Profile pic

    Hi, thanks for response. At the time I wrote, this wasn't menitioned in the description. Now it's ok.

  • 12795864?v=3

    I suggest to highlight the example in the description:


    strexpression = "5 * 4 + 6"`
    SumProd(strexpression) = "2.60000e+01"
  • Loading more items...