Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Wednesday, June 12, 2013

Learn Python the hard way 6-10

So time for some more learn python the hard way.

Ex6: more variables that can be used in place of long strings. so instead of typing the same message over and over again you can just set it to a variable and drop it where it is needed in the code.

x = "you can't go that way"
y = "sup my home skillet %s"

print x
you can't go that way

print y % x
sup my home skillet you can't go that way

print x + y % x
you can't go that way sup my home skillet you can't go that way

Ex7: added more expressions to stings and variables for instance

print "x" * 10
you will get "xxxxxxxxxx"

this can be useful for dividers

Ex8-10: just more examples of formatting and variables as well as showing the triple quotes ~

Thursday, May 30, 2013

Learn Python the hard way 2-5

Time for another update before a take a short break from python. Just grinded trough lesson 2-5 while looking for extra info on python.

I has a nice run trough of pythons operators and I now know how to use it's basic math functions. The % sigh was a bit annoying but now that I know it returns a remainder that could still be useful. another useful one is the sum([x, y, x, x, y, z ]) function which just adds these numbers together instead of you having to write them all out with addition signs.

I love how easy it is to set up a variable in python. just name = int or sting and bam! you are done. there are no need for terminators or anything it is kind of nice.

If statements trough me for a bit of a look did not realize you needed to indent the lower line for it to be apart of the statement. I am a little embarrassed at how long it to me to figure that out.

the image below is from lesson 5


Wednesday, May 29, 2013

Learn python the hard way Exercise 0-1 done

Well I though I would document my journey of learning python by posting on this blog to help collect my thoughts on what I have learned so far. Learn Python the hard was was recommended to me by both Chad Moore and Jason Park to great Tech artist in the industry. So I just dove right in to get my bearings in the environment.

While I do have some scripting background in both Javascript, c#, and mel it was high time to learn python. In    learn python the hard way it highly recommend that you use python 2 instead of python three without explain why. Me wanting to learn the most up to date python just went along and started using 3 thinking I would not get into trouble ... I was wrong. There were quite a few syntax changes from 2 to 3 but now I see this as a new challenge and an even greater way to expand upon my learning experience. Plus who does not love a good challenge.

So I fallowed instructions and learned how to make a directory in power-shell as well as other files and some other much needed basics. Then I executed the Python code with power-shell and wallah I am well on my way.

Also print text needed to be encapsulated from python 2-3 I can understand/dig it ;D