Learn SQL The Hard Way with SQLite3Descripción completa
do it the hard way
Descripción: About learning python through hard computational problem sets.
do it the hard wayFull description
Learn Python with this ebook
Learn SAP the German WayFull description
LEARNFull description
Learn German
learn spanish easyFull description
Learn German
Descripción completa
easy learning russian language
Learn GermanFull description
Exercise %,: 6esi!nin! and 6ebu!!in! Fow that you !now i+-state(ents, I'm going to gi*e you some rules for +or-loops and 8/ile-loops that will !ee you out of trouble. I'm also going to gi*e you some tis on debugging so that you can figure out roblems with your rogram. :inally, you are going to design a similar little game as in the last e&ercise but with a slight twist.
R#les &or 0f-State+ents $. 0*ery i+-state(ent must ha*e an else. . If this else should ne*er be run because it doesn't ma!e sense, then you must use a *ie function in the else that rints out an error message and dies, ust li!e we did in the last e&ercise. This will find many errors. (. Fe*er nest i+-state(ents more than dee and always try to do them $ dee. This means if you ut an i+ in an i+ then you should be loo!ing to mo*e that second i+ into another function. B. Treat i+-state(ents li!e aragrahs, where each i+,elsif,else grouing is li!e a set of sentences. Put blan! lines before and after. C. +our boolean tests should be simle. If they are comle&, mo*e their calculations to *ariables earlier in your function and use a good name for the *ariable. If you follow these simle rules, you will start writing better code than most rogrammers. %o bac! to the last e&ercise and see if I followed all of these rules. If not, fi& it. Warnin!
Fe*er be a sla*e to the rules in real life. :or training uroses you need to follow these rules to ma!e your mind strong, but in real life sometimes these rules are ust stuid. If you thin! a rule is stuid, try not using it.
R#les &or Loops $. Ese a 8/ile-loop only to loo fore*er, and that means robably ne*er. This only alies to Ruby, other languages are different. . Ese a +or-loop for all other !inds of looing, esecially if there is a fi&ed or limited number of things to loo o*er.
Tips &or De/#gging $. o not use a "debugger". - debugger is li!e doing a full1body scan on a sic! erson. +ou do not get any secific useful information, and you find a whole lot of information that doesn't hel and is ust confusing. . The best way to debug a rogram is to use puts or p to rint out the *alues of *ariables at oints in the rogram to see where they go wrong. (. )a!e sure arts of your rograms wor! as you wor! on them. o not write massi*e files of code before you try to run them. ;ode a little, run a little, fi& a little.