write 500 li es on python
class 10 students
Answers
While repetition isn't a bad idea, blind repetition isn't good because you may inadvertently pick up some of the authors original bad habits ( if they exist ) and they don't reinforce certain ideas and may cause issues with other languages.. I'd recommend working a problem based on your level of experience from scratch, or partial - solve a problem using the language or create something new...
Some things which exist in Python but not other languages: Variable Scope - now, it does exist in Python but it is incredibly lax - for instance if you create a function and create the variable in an if statement you can use the same variable outside of the if statement - but in every other language I work with ( dozens ) you have to initialize or declare the variable ahead of time otherwise anything outside of the if statement won't know what it is...
The whole idea of forced tabbing - while this is good and can help build up a coding standard for you to apply to your work for other languages, and it forces you to make the code somewhat human readable, it doesn't take it all the way... It is fantastic for the language because Python is powerful and its high level ( meaning easier to learn, use, etc. and the back end does a lot for you. ) and using tabs to designate scope or possession means less characters typed to designate scope or possession meaning much faster turn around when converting your program from the design stage to code stage... The one issue I have is many people use spaces instead of tabs which cause grossly inflated file size... To give an example I converted spaces to tabs in a file which was around 800KB in size and it took it down to 200KB... That's HUGE... It's also why I will always use tabs instead of spaces...
Some things I recommend when teaching - and these are useful all around: When you code something, any time you repeat code, turn it into a helper function... Give it an appropriate / easy name and then use it instead of the repetition everywhere...
When using a language, it isn't a bad idea to rewrite a function if it makes sense - give it a new name to retain backwards compatibility if others use your library with something else... For instance, there are draw functions which use startx, starty, endx, endy instead of simply x, y, w, h - meaning when you go to draw multiple objects ( say it is a rectangle and you want a border, using x, y, w, and h you can offset the second drawn [ which is drawn above the background / first ] by the border size in x and y, and subtract border * 2 from w and h ] - things are sometimes easier using x, y, w, h instead of start and end because the math becomes much shorter when you call the helper functions rather than the originals using start / end x / y vars )... It may not be the best case all the time, but for certain tasks it makes sense....
Create a coding standard and stick with it... A coding standard is something used by companies in the real world to ensure their code looks like it was written by a single person or by a thousand people all using an identical method... A coding standard is how you style your code... Ie I use airy declarations so instead of func(x,y,w,h): I use func( w, h, x, y ):... Additionally, I use _s to designate local, __ to designate private / internal ( which works with Python ) and none for globals... I use all upper-case variable names to designate constants and enumeration variables. I also prefer underscores in variables to separate words instead of UpperCamelCase or lowerCamelCase... All functions have 3 comment lines above them, unless single-lined then 1, with 2 empty lines above them, unless single lined then 1... The center line has a description of the function and I am leaning towards adding argument / return descriptors to automatically generate documentation... All classes have 3 comment lines above them with the center line having the description... All variables of a singular data-type have FIXED names... so _p for a Player object, _v for Vehicle, _w for Weapon, _data for a data Table, and many more ( This example is from my GMod Lua Framework but it applies to everything applicable - I use set variable names along with underscores because if I ever have an error come up then from first glance I can immediately see the scope which reduces debugging time by a LOT and the data-type supposed to be contained with the variable, etc... ) - so func( x, y, w, h ): actually looks like func( _x, _y, _w, _h ): -- Note: Python uses double-underscores for something very specific - for my purposes it doesn't affect anything adversely but make sure your coding standard works for the languages you use - It's inconvenient and costs a lot of time and money when you need a new coding standard for EVERY language especially if they are completely different from the previous - so try to stick with one method and adapt as much as you can to other languages when it isn't possible to keep the identical variant...
p