Giter Site home page Giter Site logo

subjects's Introduction

Logic training with Python

Usage of Internet is authorized.

Setup

Install requirements (with pip):

pip install -r requirements.txt

How to run test suite

Code in fill_me.py files

If you want to test your code, put your functions inside fill_me.py files.

On a specific folder

This is an example, and a good start.

pytest exercises/function
# or
python -m pytest exercises/function

On all folders

Note: You will get a lot of errors if not all required functions are implemented.

pytest
# or
python -m pytest

Rules

Forbidden python features

  • imports,
  • from imports,
  • defining functions with builtin names,
  • calls of function with builtin names except ['int', 'list', 'dict', 'bool', 'str', 'float', 'tuple', 'type', 'ord', 'chr'],
  • calls of methods (eg. 'my_list.append()'),
  • try clauses,
  • break and continue statements,
  • variables with builtin names or trailing underscore (eg. 'my_var_'),
  • for loop,
  • list comprehensions,
  • dict comprehensions,
  • set comprehensions,
  • generator expressions,
  • yield and yield from statements,
  • raise statements,
  • assert statements,
  • while else statements,
  • global statements,
  • nonlocal statements,
  • following operators on list: ['+', '+=', '==', '>=', '<=', '>', '<', '!=', '*='],
  • following operators on dict: ['+', '+=', '==', '>=', '<=', '>', '<', '!=', '*=', '|', '&'],
  • 3 args form of type,
  • class definitions,
  • in and not in operator,
  • is and is not operator,
  • positional only arguments, keyword only arguments, keywords defaults arguments, defaults arguments, variadic arguments, variadic keyword arguments,
  • slices,
  • packing and unpacking,

Respect PEP 8 style

PEP 8 is a style guide for Python. You can find it here.

You must respect two other rules:

  • Line length must be less than 80 characters,
  • Function length must be less than 25 lines.

Since you aren't allowed to use some python features, you should test your code with custom rules. This project has a setup.cfg file with a flake8 configuration, so you can run flake8 to check your code with properly excluded errors.

flake8
# or
python -m flake8

What to do if an error is found

  • If the error is raised by flake8 because you didn't use a forbidden feature, you should report it on the issue tracker.
  • If the error raised by flake8 is about complexity, you should reduce the cognitive complexity of your code.

Useful links

Copyright © 2022 Dorian Turba

subjects's People

Contributors

p1-dta avatar

Watchers

 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.