Hi All,
Below you'll find some common mistakes we found in many of the submitted solutions. Please take the extra moment to read and improve going forward.
This is an open issue so feel free to add your tips to the group.
Comment & Documentation
- Leaving Docstring: In each starter file you have a top docstring (the text inside """) that described the exercise. Please have a top docstring in each submitted solution and in each file you write. That helps others, including your future selves, understand what the script does.
- Use line comments (line starting with a
#) to describe cool things you've implemented in the solution and tell us why they're cool.
Python Style
- Use
for loop when you know the number of iterations. Use while loop when number of iterations can vary or not known in advance.
- Use all lowercase names for variables and functions. Better yet go read PEP8 (official python style guide) and use everything from there:
https://www.python.org/dev/peps/pep-0008/
- Write all
import statements at the top of the file, after the docstring.
- Prefer str.format over string concatenation
- Use descriptive variable names. Instead of
number1, x, you could use hidden_number, guess, total.
range (0,7) can be written as range (7)
- Use
raw_input("Prompt: ")
instead of
print "Prompt: "
raw_input()
Questions:
Hi All,
Below you'll find some common mistakes we found in many of the submitted solutions. Please take the extra moment to read and improve going forward.
This is an open issue so feel free to add your tips to the group.
Comment & Documentation
#) to describe cool things you've implemented in the solution and tell us why they're cool.Python Style
forloop when you know the number of iterations. Usewhileloop when number of iterations can vary or not known in advance.https://www.python.org/dev/peps/pep-0008/
importstatements at the top of the file, after the docstring.number1,x, you could usehidden_number,guess,total.range (0,7)can be written asrange (7)raw_input("Prompt: ")instead of
Questions:
https://github.com/ynonp/python-examples-verint-2016-07/pulls?utf8=%E2%9C%93&q=is%3Apr
You can also put author:USERNAME in the filter box on that page to see only those of user USERNAME.