>> s = “TAGAGAATTCTA” >>> t = “GAAT” >>>"> >> s = “TAGAGAATTCTA” >>> t = “GAAT” >>>">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Variables and References in Python. "TAGAGAATTCTA” Objects s Names References >>> s = “TAGAGAATTCTA” >>>

Similar presentations


Presentation on theme: "Variables and References in Python. "TAGAGAATTCTA” Objects s Names References >>> s = “TAGAGAATTCTA” >>>"— Presentation transcript:

1 Variables and References in Python

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

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

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

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

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

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

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

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

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

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

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

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

14 [2, 4, 5, 7] Objects L1 L2 Names 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] Objects L1 L2 Names 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] Objects L1 L2 Names 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] [2, 5, 7] Objects L1 L2 Names 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 >>>


Download ppt "Variables and References in Python. "TAGAGAATTCTA” Objects s Names References >>> s = “TAGAGAATTCTA” >>>"

Similar presentations


Ads by Google