Code Monkey home page Code Monkey logo

fix-a-bug's Introduction

๐Ÿ›  fix-a-bug

Setup

Clone this repo.

git clone https://github.com/datamade/fix-a-bug.git && cd fix-a-bug

Install the requirements. (Feel free to use a virtual environment!)

pip install -r requirements.txt

Run the tests.

pytest -sv

Challenge

The code in fix_me.py contains four errors that are preventing the test from passing. Debug and correct each error. As you identify the errors, fill out a description of the problem and an explanation of the root cause and your fix in the section below.

Error 1

Description: The get_previous() method does not return zero when there is no previous value.

Explanation: The only situation in which there wouldn't be a previous value is when the method is trying to find the previous value of the first value in the list -- by definition, it doesn't have a previous value. To fix it, I set up a conditional where, if the index of the value is 0, the method should just return 0.

Error 2

Description: The test throws an error about an index value being out of range.

Explanation: When using enumerate(), the first variable made available is the index. The variables were misnamed, which I was able to verify by printing the variables with a message identifying them. To solve this, I flipped the names so that the variables within this method would be defined semantically.

Error 3

Description: The tests throw an error: "TypeError: 'int' object is not iterable" in line 32.

Explanation: The sum() method in Python requires the first argument to be iterable, like a list or tuple. Since in this line, we are just trying to add one number to another, it makes more sense to use the addition operator.

Error 4

Description: The test is failing because the output is not what is expected.

Explanation: The subclass Transformer was being defined as an extention of both ParentA and ParentB. Transformer should only have one parent class.

Also, based on the output of the test, it looks like Transformer was being treated as a child of the ParentA superclass. Since this was not producing the desired output, I tried making ParentB the superclass. This made Transformer pass the test.

fix-a-bug's People

Contributors

hancush avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.