Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lfa:2023:coding-style [2023/11/06 16:04]
mihai.udubasa
lfa:2023:coding-style [2023/11/06 16:07] (current)
mihai.udubasa [Example code]
Line 122: Line 122:
  
 ==== Redundant and trivially simplifiable code ==== ==== Redundant and trivially simplifiable code ====
- 
 This includes: This includes:
- ​- ​unreachable code, +  * unreachable code, 
- expressions with no effect +  ​* ​expressions with no effect 
- unused variables +  ​* ​unused variables 
- redundant code and expressions written in an overcomplicated manner (using extra unneeded statements or harder-to-read versions of statements, such as dunders instead of builtins). +  ​* ​redundant code and expressions written in an overcomplicated manner (using extra unneeded statements or harder-to-read versions of statements, such as dunders instead of builtins). 
- use of improper iteration methods (for example, iterating over the range of indices and then accessing a list directly in the loop, instead of iterating over the list)+  ​* ​use of improper iteration methods (for example, iterating over the range of indices and then accessing a list directly in the loop, instead of iterating over the list)
 <​hidden>​ <​hidden>​
 <code python> <code python>
-inport time # this import is not used 
- 
 def f(): def f():
     x = 1  # this value is never used     x = 1  # this value is never used
Line 148: Line 145:
        else:        else:
            ​return False            ​return False
-           +
 h = lambda x: x + 1 # use a more easily readable function def h = lambda x: x + 1 # use a more easily readable function def
  
Line 366: Line 363:
 Here are some small examples of possible code submissions for a very simple task, one which is penalised, one which recieves regular points and one which also recieves a bonus. Here are some small examples of possible code submissions for a very simple task, one which is penalised, one which recieves regular points and one which also recieves a bonus.
  
-The given task is to create a module ​+TODO: decide ​task and give example code