Tuesday, September 23, 2008

Chapter 1

Its official, we are under way with our learning of Python. Chapter 1 is to introduce you to this new language. This will be prevalent throughout the following 2 chapters. If you are a beginning programmer, like me, at the end of this chapter we will have learned some simple guiding principles for programming. A key concept that Python wants the programmer to do is to think in blocks. This blocking technique allows you to think about larger projects in little pieces. This allows the programmer to make it understandable in many parts so you can extend the program farther if need be.  So for this first chapter, I just wanted to experiment with different types of strings.  The first thing I entered in was to use quotes: 

"Let see how python works" . This came back with the response 
'Let see how python works'.  

If I want to split the sentence up all I need to use is \n.  \n stands for new line. The only way for it to read it as a special character, you must have it translated to print.  

"Let see how \n  python works" won't make a new line.
a) print "Let see how \n python works"

'Let see how 
python works'

(The exercises clarify how \n works)

If you want to combine strings, it is just like Java. All you need is a + in between what you are writing.  
 

No comments: