Study of Life: Biology Basics - Cells, Growth, Reproduction, and More

Study of Life: Biology Basics - Cells, Growth, Reproduction, and More
Slide Note
Embed
Share

Explore the fascinating realm of biology with a focus on the basic principles of life. Discover the organization of living things, processes of growth and development, reproduction methods, adaptation to the environment, energy metabolism, and the concept of evolution. Dive into understanding what constitutes living entities and differentiate them from nonliving things through examples ranging from cells and organisms to natural elements. Gain insight into the fundamental aspects of life and how living organisms interact with their surroundings.

  • Biology
  • Life Science
  • Cells
  • Reproduction
  • Evolution

Uploaded on Apr 04, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Introduction to Computing Using Python >>> 'Hello, World!' 'Hello, World!' >>> >>> s = 'rock' >>> t = 'climbing' >>> >>> 'Hello, World!' 'Hello, World!' Strings In addition to number and Boolean values, Python support string values "Hello, World!" 'Hello, World!' A string value is represented as a sequence of characters enclosed within quotes A string value can be assigned to a variable String values can be manipulated using string operators and functions

  2. Introduction to Computing Using Python >>> 'Hello, World!' 'Hello, World!' >>> s = 'rock' >>> t = 'climbing' >>> s == 'rock' True >>> s != t True >>> s < t False >>> s > t True >>> s + t 'rockclimbing' >>> s + ' ' + t 'rock climbing' >>> 5 * s 'rockrockrockrockrock' >>> 30 * '_' '______________________________' >>> 'o' in s True >>> 'o' in t False >>> 'bi' in t True >>> len(t) 8 String operators Usage x in s x not in s s + t s * n, n * s s[i] len(s) Explanation x is a substring of s x is not a substring of s Concatenation of s and t Concatenation of n copies of s Character at index i of s (function) Length of string s To view all operators, use the help() tool >> help(str) Help on class str in module builtins: class str(object) | str(string[, encoding[, errors]]) -> str ...

  3. Introduction to Computing Using Python Exercise Write Python expressions involving strings s1, s2, and s3 that correspond to: >>> s1 'good' >>> s2 'bad' >>> s3 'silly' >>> >>> 'll' in s3 True >>> ' ' not in s1 True >>> s1 + s2 + s3 'goodbadsilly >>> ' ' in s1 + s2 + s3 False >>> 10*s3 'sillysillysillysillysillysill ysillysillysillysilly' >>> len(s1+s2+s3) 12 >>> >>> s1 'good' >>> s2 'bad' >>> s3 'silly' a) 'll' appears in s3 b) the blank space does not appear in s1 c) the concatenation of s1, s2, and s3 d) the blank space appears in the concatenation of s1, s2, and s3 e) the concatenation of 10 copies of s3 f) the total number of characters in the concatenation of s1, s2, and s3

  4. Introduction to Computing Using Python Index and indexing operator The index of an item in a sequence is its position with respect to the first item The index of an item in a sequence is its position with respect to the first item The first item has index 0, The index of an item in a sequence is its position with respect to the first item The index of an item in a sequence is its position with respect to the first item The first item has index 0, The first item has index 0, The second has index 1, The second has index 1, The third has index 2, The indexing operator [] takes a nonnegative index i and returns a string consisting of the single character at index i ' A p p l e ' s = 0 1 2 3 4 'A' s[0] = 'p' >>> s = 'Apple' >>> s[0] 'A' >>> s[1] 'p' >>> s[4] 'e' s[1] = 'p' s[2] = 'l' s[3] = 'e' s[4] =

  5. Introduction to Computing Using Python Negative index A negative index is used to specify a position with respect to the end The last item has index -1, The second to last item has index -2, The third to last item has index -3, -5 -4 -3 -2 -1 ' A p p l e ' s = 0 1 2 3 4 'e' s[-1] = 'l' >>> s = 'Apple' >>> s[-1] 'e' >>> s[-2] 'l' >>> s[-5] 'A' s[-2] = 'A' s[-5] =

  6. Introduction to Computing Using Python Exercise String s is defined to be 'abcdefgh' Write expressions using s and the indexing operator [] that return the following strings: >>> s = 'abcdefgh' >>> >>> s[0] 'a' >>> s[2] 'c' >>> s[7] 'h' >>> s[-1] 'h' >>> s[-3] 'f' >>> >>> s = 'abcdefgh' a) 'a' b) 'c' c) 'h' d) 'f'

  7. Introduction to Computing Using Python String representations A string value is represented as a sequence of characters delimited by quotes Quotes can be single (') or double (") >>> excuse = 'I am sick' >>> excuse = "I am sick" >>> >>> excuse = 'I'm sick' SyntaxError: invalid syntax >>> >>> excuse = "I'm sick" >>> >>> excuse = "I'm "sick"" SyntaxError: invalid syntax >>> excuse = 'I'm "sick"' SyntaxError: invalid syntax >>> >>> excuse = 'I\'m "sick"' >>> >>> excuse 'I\'m "sick"' >>> >>> print(excuse) I'm "sick" >>> >>> excuse = 'I\'m ...\n... "sick"' >>> >>> excuse 'I\'m ...\n... "sick"' >>> >>> print(excuse) I'm ... ... "sick" >>> excuse = 'I am sick' >>> excuse = "I am sick" >>> excuse = "I am sick" >>> excuse = 'I'm sick' SyntaxError: invalid syntax SyntaxError: invalid syntax >>> excuse = "I'm sick" >>> excuse = "I'm sick" >>> excuse = "I'm "sick"" SyntaxError: invalid syntax >>> excuse = 'I'm "sick"' SyntaxError: invalid syntax SyntaxError: invalid syntax >>> excuse = 'I\'m "sick"' >>> excuse = 'I\'m "sick"' >>> excuse 'I\'m "sick"' 'I\'m "sick"' >>> print(excuse) I'm "sick I'm "sick >>> excuse = 'I\'m ...\n... "sick"' >>> excuse = 'I\'m ...\n... "sick"' >>> excuse 'I\'m ...\n... "sick"' >>> excuse = 'I am sick' >>> excuse = 'I am sick' >>> excuse = "I am sick" >>> excuse = 'I'm sick' >>> excuse = 'I'm sick' SyntaxError: invalid syntax SyntaxError: invalid syntax >>> excuse = "I'm sick" >>> excuse = "I'm "sick"" SyntaxError: invalid syntax >>> excuse = 'I'm "sick"' >>> excuse = 'I'm "sick"' SyntaxError: invalid syntax SyntaxError: invalid syntax >>> excuse = 'I\'m "sick"' >>> excuse >>> excuse 'I\'m "sick"' >>> print(excuse) >>> print(excuse) I'm "sick >>> excuse = 'I am sick' >>> excuse = "I am sick" >>> excuse = "I am sick" >>> excuse = 'I'm sick' >>> excuse = 'I'm sick' SyntaxError: invalid syntax >>> excuse = "I'm sick" >>> excuse = "I'm "sick"" SyntaxError: invalid syntax SyntaxError: invalid syntax >>> excuse = 'I'm "sick"' >>> excuse = 'I'm "sick"' SyntaxError: invalid syntax >>> excuse = 'I\'m "sick"' >>> excuse = 'I\'m "sick"' >>> excuse 'I\'m "sick"' >>> excuse = 'I am sick' >>> excuse = 'I am sick' >>> excuse = "I am sick" >>> excuse = "I am sick" >>> excuse = 'I'm sick' SyntaxError: invalid syntax >>> excuse = "I'm sick" >>> excuse = "I'm "sick"" >>> excuse = "I'm "sick"" SyntaxError: invalid syntax SyntaxError: invalid syntax >>> excuse = 'I'm "sick"' SyntaxError: invalid syntax >>> excuse = 'I am sick' >>> excuse = 'I am sick' >>> excuse = "I am sick" >>> excuse = 'I'm sick' SyntaxError: invalid syntax >>> excuse = "I'm sick >>> excuse = "I'm sick" >>> excuse = "I'm "sick"" >>> excuse = 'I am sick' >>> excuse = "I am sick" >>> excuse = 'I'm sick' SyntaxError: invalid syntax What if ' or " is one of the string characters? both ' and "? What if the string includes Escape sequence \' or \" is used to indicate that a quote is not the string delimiter but is part of the string value Function print() interprets the escape sequence Another example: \n is an escape sequence that represents a new line

  8. Introduction to Computing Using Python Indexing operator, revisited s[i:j] : the slice of s starting at index i and ending before index j s[i:] : the slice of s starting at index i s[:j] : the slice of s ending before index j The indexing operator can also be used to obtain a slice of a The indexing operator returns the character at index i (as a single character string). string -5 -4 -3 -2 -1 ' A p p l e ' s = 0 1 2 3 4 >>> s = 'Apple' >>> s[0:2] 'Ap' >>> s[1:4] 'ppl' >>> s[2:5] 'ple' >>> s[2:] 'ple' s[0:2] = 'Ap' 'A' s[0] = 'p' 'ppl' >>> s = 'Apple' >>> s[0] 'A' >>> s[1] 'p' >>> s[4] 'e' >>> s[:2] 'Ap' >>> s[-3:-1] 'pl' s[1] = s[1:4] = 'p' 'ple' 'ple' s[2] s[2:5] = = 'l' s[3] = s[2:] = s[:2] = 'Ap' 'e' s[4] = 'pl' s[-3:-1] =

  9. Introduction to Computing Using Python Exercise The indexing operator can also be used to obtain slices of a list as well. Let list lst refer to list ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h ] Write Python expressions using list lst and the indexing operator that evaluate to: a) ['a', 'b', 'c', 'd'] b) ['d', 'e', 'f'] c) ['d'] d) ['f', 'g'] e) ['d', 'e', 'f', 'g , 'h'] f) ['f', 'g', 'h'] >>> lst[:4] ['a', 'b', 'c', 'd'] >>> lst[3:6] ['d', 'e', 'f'] >>> lst[3:4] ['d'] >>> lst[-3:-1] ['f', 'g'] >>> lst[3:] ['d', 'e', 'f', 'g , 'h'] >>> lst[-3:] ['f', 'g', 'h']

  10. Introduction to Computing Using Python String methods Usage Explanation >>> link = 'http://www.main.com/smith/index.html' s.capitalize() >>> link[:4] 'http' >>> link[:4].upper() 'HTTP' >>> link.find('smith') 20 >>> link[20:25] 'smith' >>> link[20:25].capitalize() 'Smith' >>> link.replace('smith', 'ferreira') 'http://www.main.com/ferreira/index.html' >>> link 'http://www.main.com/smith/index.html' >>> new = link.replace('smith', 'ferreira') >>> new 'http://www.main.com/ferreira/index.html' >>> link.count('/') 4 >>> link.split('/') ['http:', '', 'www.main.com', 'smith', 'index.html'] returns a copy of s with first character capitalized s.count(target) returns the number of occurences of target in s s.find(target) returns the index of the first occurrence of target in s returns lowercase copy of s returns copy of s with every occurrence of old replaced with new returns list of substrings of s, delimited by sep returns copy of s without leading and trailing whitespace returns lowercase copy of s Strings are immutable; none of the string methods modify Strings are immutable; none of the string methods modify string link string s s.lower() s.replace(old, new) s.split(sep) s.strip() s.upper()

  11. Python String join() The join() string method returns a string by joining all the elements of an iterable, separated by a string separator. # .join() with lists numList = ['1', '2', '3', '4'] separator = ', ' print(separator.join(numList)) # .join() with tuples numTuple = ('1', '2', '3', '4') print(separator.join(numTuple)) s1 = 'abc' s2 = '123' # each element of s2 is separated by s1 # '1'+ 'abc'+ '2'+ 'abc'+ '3' print('s1.join(s2):', s1.join(s2)) 1, 2, 3, 4 1, 2, 3, 4 s1.join(s2): 1abc2abc3 s2.join(s1): a123b123c # each element of s1 is separated by s2 # 'a'+ '123'+ 'b'+ '123'+ 'b' print('s2.join(s1):', s2.join(s1))

  12. Introduction to Computing Using Python Exercise >>> events = '9/13 2:30 PM\n9/14 11:15 AM\n9/14 1:00 PM\n9/15 9:00 AM' >>> print(events) 9/13 2:30 PM 9/14 11:15 AM 9/14 1:00 PM 9/15 9:00 AM String events describes the schedule of 4 events spread across 3 days >>> events.count('9/14') 2 >>> events.find('9/14') 13 >>> events.find('9/15') 40 >>> events[13:40] '9/14 11:15 AM\n9/14 1:00 PM\n >>> lst = events[13:40].strip().split('\n') >>> lst ['9/14 11:15 AM', '9/14 1:00 PM'] >>> Write expressions that compute: a) the number of events on 9/14 b)the index of the substring describing the 1st event on 9/14 c) the index just past the substring describing the last event on 9/14 d)the list of substrings describing the events on 9/14

  13. Introduction to Computing Using Python Built-in function print(), revisited their string representation Function print() takes 0 or more arguments and prints them in the shell >>> prod = 'morels' >>> cost = 139 >>> wght = 1/2 >>> total = cost * wght >>> >>> print(prod, cost, wght, total) morels 139 0.5 69.5 >>> >>> print(prod, cost, wght, total, sep='; ') morels; 139; 0.5; 69.5 >>> >>> print(prod, cost, wght, total, sep=':::') morels:::139:::0.5:::69.5 >>> >>> prod = 'morels' >>> cost = 139 >>> wght = 1/2 >>> total = cost * wght >>> total = cost * wght >>> print(prod, cost, wght, total) morels 139 0.5 69.5 morels 139 0.5 69.5 >>> print(prod, cost, wght, total, sep='; ') morels; 139; 0.5; 69.5 >>> prod = 'morels' >>> cost = 139 >>> wght = 1/2 >>> wght = 1/2 >>> total = cost * wght >>> print(prod, cost, wght, total) >>> prod = 'morels' >>> cost = 139 A blank space separator is printed between the arguments The sep argument allows for customized separators

  14. Introduction to Computing Using Python Built-in function print(), revisited Function print() prints, by default, a newline character after printing its arguments >>> pets = ['boa', 'cat', 'dog'] >>> for pet in pets: print(pet) print(pet) print(pet) print(pet) >>> pets = ['boa', 'cat', 'dog'] >>> for pet in pets: >>> for pet in pets: >>> for pet in pets: >>> pets = ['boa', 'cat', 'dog'] >>> pets = ['boa', 'cat', 'dog'] boa cat dog >>> >>> >>> for pet in pets: print(pet, end=', ') print(pet, end=', ') boa\n cat\n dog\n dog dog >>> for pet in pets: boa cat cat boa boa, cat, dog, >>> >>> for pet in pets: print(pet, end='!!! ') boa, cat, dog, boa!!! cat!!! dog!!! >>> The end argument allows for customized end characters

  15. Introduction to Computing Using Python General output formatting Suppose we have >>> weekday = 'Wednesday' >>> month = 'March' >>> day = 10 >>> year = 2010 >>> hour = 11 >>> minute = 45 >>> second = 33 >>> >>> print(hour+':'+minute+':'+second) Traceback (most recent call last): File "<pyshell#113>", line 1, in <module> print(hour+':'+minute+':'+second) TypeError: unsupported operand type(s) for +: 'int' and 'str' >>> >>> print(str(hour)+':'+str(minute)+':'+str(second)) 11:45:33 >>> >>> print('{}:{}:{}'.format(hour, minute, second)) 11:45:33 >>> weekday = 'Wednesday' >>> month = 'March' >>> day = 10 >>> year = 2010 >>> hour = 11 >>> minute = 45 >>> second = 33 >>> second = 33 >>> print(hour+':'+minute+':'+second) Traceback (most recent call last): File "<pyshell#113>", line 1, in <module> print(hour+':'+minute+':'+second) TypeError: unsupported operand type(s) for +: 'int' and 'str' TypeError: unsupported operand type(s) for +: 'int' and 'str' >>> print(str(hour)+':'+str(minute)+':'+str(second)) 11:45:33 >>> weekday = 'Wednesday' >>> month = 'March' >>> day = 10 >>> year = 2010 >>> hour = 11 >>> minute = 45 >>> minute = 45 >>> second = 33 >>> print(hour+':'+minute+':'+second) Traceback (most recent call last): File "<pyshell#113>", line 1, in <module> print(hour+':'+minute+':'+second) >>> weekday = 'Wednesday' >>> month = 'March' >>> day = 10 >>> year = 2010 >>> hour = 11 and we want to print Wednesday, March 10, 2010 at 11:45:33

  16. Introduction to Computing Using Python Method format() of class str >>> day = 'Wednesday' >>> month = 'March' >>> weekday = 'Wednesday' >>> month = 'March' >>> day = 10 >>> year = 2010 >>> year = 2012 >>> hour = 11 >>> minute = 45 >>> second = 33 >>> print('{}:{}:{}'.format(hour, minute, second)) 11:45:33 >>> >>> print('{}, {} {}, {} at {}:{}:{}'.format(weekday, month, day, year, hour, minute, second)) Wednesday, March 10, 2012 at 11:45:33 >>> day = 'Wednesday' >>> month = 'March' >>> weekday = 'Wednesday' >>> month = 'March' >>> day = 10 >>> year = 2010 >>> year = 2012 >>> hour = 11 >>> minute = 45 >>> second = 33 >>> print('{}:{}:{}'.format(hour, minute, second)) 11:45:33 format string print('{}:{}:{}'.format(hour, minute, second)) placeholders

  17. Introduction to Computing Using Python Specifying field width >>> for i in range(1,8): print(i, i**2, 2**i) The format() method can be used to line up data in columns >>> for i in range(1,8): print(i, i**2, 2**i) 1 1 2 2 4 4 3 9 8 4 16 16 5 25 32 6 36 64 7 49 128 >>> for i in range(1, 8): print('{} {:2} {:3}'.format(i, i**2, 2**i)) 1 1 2 2 4 4 3 9 8 4 16 16 5 25 32 6 36 64 7 49 128 >>> Numbers are aligned to the right 1 1 2 2 4 4 3 9 8 4 16 16 5 25 32 6 36 64 7 49 128 >>> reserves 2 spaces for i**2 plus a blank space between the columns reserves 3 spaces for 2**i

  18. Introduction to Computing Using Python Specifying field width The format() method can be used to line up data in columns >>> lst = ['Alan Turing', 'Ken Thompson', 'Vint Cerf'] >>> for name in lst: fl = name.split() print(fl[0], fl[1]) print(fl[0], fl[1]) >>> lst = ['Alan Turing', 'Ken Thompson', 'Vint Cerf'] >>> for name in lst: fl = name.split() Alan Turing Ken Thompson Vint Cerf >>> >>> for name in lst: fl = name.split() print('{:5} {:10}'.format(fl[0], fl[1])) Alan Turing Ken Thompson Vint Cerf Numbers are aligned to the right Strings are aligned to the left Alan Turing Ken Thompson Vint Cerf >>>

  19. Introduction to Computing Using Python Output format type Inside the curly braces of a placeholder, we can specify the field width Inside the curly braces of a placeholder, we can specify the field width, the type of the output type of the output, and the decimal precision Inside the curly braces of a placeholder, we can specify the field width, the >>> n = 10 >>> '{:b}'.format(n) '1010' >>> '{:c}'.format(n) '\n' >>> '{:d}'.format(n) '10' >>> '{:X}'.format(n) 'A' >>> '{:e}'.format(n) '1.000000e+01' >>> n = 10 >>> '{:b}'.format(n) '1010' >>> '{:c}'.format(n) '\n' >>> '{:d}'.format(n) '10' >>> '{:X}'.format(n) 'A' >>> '{:e}'.format(n) '1.000000e+01' >>> >>> '{:7.2f}'.format(n) ' 10.00' >>> '{:7.2f}' Type b c d X e f Explanation binary field width character decimal precision decimal hexadecimal scientific fixed-point

More Related Content