1 / 17

Variables and References in Python

Variables and References in Python. "TAGAGAATTCTA”. s. Names. Objects. References. >>> s = “TAGAGAATTCTA” >>>. "TAGAGAATTCTA". s. "GAAT". t. Names. Objects. References. >>> s = “TAGAGAATTCTA” >>> t = “GAAT” >>>. "TAGAGAATTCTA". s. "GAAT". t. 4. i. Names. Objects.

ivory
Download Presentation

Variables and References in Python

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Variables and References in Python

  2. "TAGAGAATTCTA” s Names Objects References >>> s = “TAGAGAATTCTA” >>>

  3. "TAGAGAATTCTA" s "GAAT" t Names Objects References >>> s = “TAGAGAATTCTA” >>> t = “GAAT” >>>

  4. "TAGAGAATTCTA" s "GAAT" t 4 i Names Objects References >>> s = “TAGAGAATTCTA” >>> t = “GAAT” >>> i = s.find(t) >>> print i 4 >>> Strings have a “find” method

  5. "TAGAGAATTCTA" s "GAAT" t 4 i Names Objects References >>> s = “TAGAGAATTCTA” >>> t = “GAAT” >>> i = s.find(t) >>> print i 4 >>> t = s >>>

  6. "TAGAGAATTCTA" s t 4 i Names Objects References >>> s = “TAGAGAATTCTA” >>> t = “GAAT” >>> i = s.find(t) >>> print i 4 >>> t = s >>>

  7. "TAGAGAATTCTA" s t 4 i Names Objects References >>> s = “TAGAGAATTCTA” >>> t = “GAAT” >>> i = s.find(t) >>> print i 4 >>> t = s >>> a Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'a' is not defined >>>

  8. "TAGAGAATTCTA" s "GA" t 4 i Names Objects References >>> s = “TAGAGAATTCTA” >>> t = “GAAT” >>> i = s.find(t) >>> print i 4 >>> t = s >>> a Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'a' is not defined >>> s = “GA” >>> print t TAGAGAATTCTA >>>

  9. s "GA" 4 i Names Objects References >>> s = “TAGAGAATTCTA” >>> t = “GAAT” >>> i = s.find(t) >>> print i 4 >>> t = s >>> a Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'a' is not defined >>> s = “GA” >>> print t TAGAGAATTCTA >>> del t >>>

  10. s "GA" 4 i Names Objects References >>> s = “TAGAGAATTCTA” >>> t = “GAAT” >>> i = s.find(t) >>> print i 4 >>> t = s >>> print a Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'a' is not defined >>> s = “GA” >>> print t TAGAGAATTCTA >>> del t >>> print t Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 't' is not defined >>>

  11. [2, 4] L1 Names Objects References >>> L1 = [2, 4] >>>

  12. [2, 4, 5] L1 Names Objects References >>> L1 = [2, 4] >>> L1.append(5) >>>

  13. [2, 4, 5] L1 L2 Names Objects References >>> L1 = [2, 4] >>> L1.append(5) >>> L2 = L1 >>>

  14. [2, 4, 5, 7] L1 L2 Names Objects References >>> L1 = [2, 4] >>> L1.append(5) >>> L2 = L1 >>> L2.append(7) >>> print L1 [2, 4, 5, 7] >>> print L2 [2, 4, 5, 7] >>>

  15. [2, 5, 7] L1 L2 Names Objects References >>> L1 = [2, 4] >>> L1.append(5) >>> L2 = L1 >>> L2.append(7) >>> print L1 [2, 4, 5, 7] >>> print L2 [2, 4, 5, 7] >>> del L2[1] >>>

  16. [2, 5, 7] L1 [2, 5, 7] L2 Names Objects References >>> L1 = [2, 4] >>> L1.append(5) >>> L2 = L1 >>> L2.append(7) >>> print L1 [2, 4, 5, 7] >>> print L2 [2, 4, 5, 7] >>> del L2[1] >>> L2 = L1[:] >>> L1 == L2 True >>>

  17. [7, 5, 2] L1 [2, 5, 7] L2 Names Objects References >>> L1 = [2, 4] >>> L1.append(5) >>> L2 = L1 >>> L2.append(7) >>> print L1 [2, 4, 5, 7] >>> print L2 [2, 4, 5, 7] >>> del L2[1] >>> L2 = L1[:] >>> L1 == L2 True >>> L1.reverse() >>> L1 == L2 False >>>

More Related