From: Learn By on 14 Jul 2010 22:23 http://learnbyexamples.org 1.1. First session 1.1.1. Let’s run the python interpreter Python 2.4.2 (#1, Dec 20 2005, 16:25:40) [GCC 4.0.0 (Apple Computer, Inc. build 5026)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 1 + 5 6 >>> 2 * 5 10 >>> 1 / 2 0 Is it the right answer? >>> float(1 / 2) 0.0 >>> 1 / 2.0 0.5 >>> float(1)/2 0.5 >>> 'aaa' 'aaa' >>> len('aaa') 3 What happened? >>> len('aaa') + len('ttt') 6 >>> len('aaa') + len('ttt') + 1 7 >>> 'aaa' + 'ttt' 'aaattt' >>> 'aaa' + 5 Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: cannot concatenate 'str' and 'int' objects What does the error message mean? 'str' objects are character strings ('aaa' is a string of characters). 'int' objects are integer. You can check what the values you manipulate are, or, in programming languages parlance, what their type is: >>> type(1) <type 'int'> >>> type('1') <type 'str'> >>> type(1.0) <type 'float'> http://learnbyexamples.org/python/python-tutorial/python-tutorial-1-introduction.html
From: per isakson on 14 Jul 2010 23:04 "Learn By " <learnbyexamples.org(a)gmail.com> wrote in message <i1lrea$775$1(a)fred.mathworks.com>... > http://learnbyexamples.org > There are some Malab stuff here: http://learnbyexamples.org/?s=matlab / per
|
Pages: 1 Prev: OPC standalone problem Next: Using mmap to plot streamlines |