Attachment 'lec3.py'

Download

   1 ####################
   2 ## EXAMPLE: for loops over strings
   3 ####################
   4 #s = "demo loops"
   5 #for index in range(len(s)):
   6 #    if s[index] == 'i' or s[index] == 'u':
   7 #        print("There is an i or u")
   8 #
   9 #for char in s:
  10 #    if char == 'i' or char == 'u':
  11 #        print("There is an i or u")
  12 
  13 
  14 ####################
  15 ## EXAMPLE: while loops and strings
  16 ## CHALLENGE: rewrite while loop with a for loop
  17 ####################
  18 #an_letters = "aefhilmnorsxAEFHILMNORSX"
  19 #word = input("I will cheer for you! Enter a word: ")
  20 #times = int(input("Enthusiasm level (1-10): "))
  21 #
  22 #i = 0
  23 #while i < len(word):
  24 #    char = word[i]
  25 #    if char in an_letters:
  26 #        print("Give me an " + char + "! " + char)
  27 #    else:
  28 #        print("Give me a  " + char + "! " + char)
  29 #    i += 1
  30 #print("What does that spell?")
  31 #for i in range(times):
  32 #    print(word, "!!!")
  33 
  34 
  35     
  36 ####################
  37 ## EXAMPLE: perfect cube 
  38 ####################
  39 #cube = 27
  40 ##cube = 8120601
  41 #for guess in range(cube+1):
  42 #    if guess**3 == cube:
  43 #        print("Cube root of", cube, "is", guess)
  44 #        # loops keeps going even after found the cube root
  45     
  46 
  47 ####################
  48 ## EXAMPLE: guess and check cube root 
  49 ####################
  50 #cube = 27
  51 ##cube = 8120601
  52 #for guess in range(abs(cube)+1):
  53 #    # passed all potential cube roots
  54 #    if guess**3 >= abs(cube):
  55 #        # no need to keep searching
  56 #        break
  57 #if guess**3 != abs(cube):
  58 #    print(cube, 'is not a perfect cube')
  59 #else:
  60 #    if cube < 0:
  61 #        guess = -guess
  62 #    print('Cube root of ' + str(cube) + ' is ' + str(guess))
  63 
  64 
  65 ####################
  66 ## EXAMPLE: approximate cube root 
  67 ####################
  68 #cube = 27
  69 ##cube = 8120601
  70 ##cube = 10000
  71 #epsilon = 0.1
  72 #guess = 0.0
  73 #increment = 0.01
  74 #num_guesses = 0
  75 ## look for close enough answer and make sure
  76 ## didn't accidentally skip the close enough bound
  77 #while abs(guess**3 - cube) >= epsilon and guess <= cube:
  78 #    guess += increment
  79 #    num_guesses += 1
  80 #print('num_guesses =', num_guesses)
  81 #if abs(guess**3 - cube) >= epsilon:
  82 #    print('Failed on cube root of', cube, "with these parameters.")
  83 #else:
  84 #    print(guess, 'is close to the cube root of', cube)
  85 
  86 
  87 ####################
  88 ## EXAMPLE: bisection cube root (only positive cubes!)
  89 ####################
  90 #cube = 27
  91 ##cube = 8120601
  92 ## won't work with x < 1 because initial upper bound is less than ans
  93 ##cube = 0.25
  94 #epsilon = 0.01
  95 #num_guesses = 0
  96 #low = 0
  97 #high = cube
  98 #guess = (high + low)/2.0
  99 #while abs(guess**3 - cube) >= epsilon:
 100 #    if guess**3 < cube:
 101 #        # look only in upper half search space
 102 #        low = guess
 103 #    else:
 104 #        # look only in lower half search space
 105 #        high = guess
 106 #    # next guess is halfway in search space
 107 #    guess = (high + low)/2.0
 108 #    num_guesses += 1
 109 #print('num_guesses =', num_guesses)
 110 #print(guess, 'is close to the cube root of', cube)
 111    

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2017-07-27 19:18:45, 142.4 KB) [[attachment:Acetaminophen_PBPK.cps]]
  • [get | view] (2017-07-31 17:20:41, 1449.3 KB) [[attachment:Andy RK.zip]]
  • [get | view] (2017-07-27 19:18:53, 59.4 KB) [[attachment:BIOMD0000000619.xml]]
  • [get | view] (2017-08-09 16:50:30, 13731.9 KB) [[attachment:Belmonte_thesis.pdf]]
  • [get | view] (2017-07-27 19:33:15, 98.1 KB) [[attachment:Bloomington_and_WoodburnHall.pdf]]
  • [get | view] (2017-08-02 19:58:08, 69593.2 KB) [[attachment:CC3D Intro.pptx]]
  • [get | view] (2017-07-31 16:33:05, 1585.0 KB) [[attachment:CC3D-Computational-TB-Ruggiero.pptx]]
  • [get | view] (2017-07-31 13:39:48, 110507.5 KB) [[attachment:CC3D-Lecture Morning 1 August 2017v4-1.pptx]]
  • [get | view] (2017-07-27 15:39:09, 91.8 KB) [[attachment:CC3D_Quick_Reference_Guide.pdf]]
  • [get | view] (2017-07-27 16:26:46, 43.9 KB) [[attachment:CC3D_card.png]]
  • [get | view] (2017-08-04 21:45:14, 189.5 KB) [[attachment:CancerFLowchart.bmp]]
  • [get | view] (2017-08-04 21:38:26, 180.5 KB) [[attachment:CancerFlowCgart.pdf]]
  • [get | view] (2017-08-04 17:24:52, 5066.1 KB) [[attachment:CellCompartmentsAndLinks.pptx]]
  • [get | view] (2017-08-01 16:43:08, 27.8 KB) [[attachment:Chaotic Lorenz in COPASI.cps]]
  • [get | view] (2017-07-27 19:19:01, 1.1 KB) [[attachment:Critchley_human_APAP_data.csv]]
  • [get | view] (2017-08-02 14:44:17, 550.8 KB) [[attachment:Defining ODEs in COPASI--SBML.pptx]]
  • [get | view] (2017-07-27 19:33:23, 461.2 KB) [[attachment:Detailed_IU_map.png]]
  • [get | view] (2017-08-04 17:40:32, 7.2 KB) [[attachment:DirectedMovement.zip]]
  • [get | view] (2017-08-06 15:35:34, 6.4 KB) [[attachment:EpithelialSheet.zip]]
  • [get | view] (2017-08-04 20:15:18, 3.4 KB) [[attachment:HeikosModel (2).zip]]
  • [get | view] (2017-08-02 16:55:16, 1753.5 KB) [[attachment:Hirashima_et_al-2017-Development_Growt.pdf]]
  • [get | view] (2017-08-04 18:09:11, 132.3 KB) [[attachment:Josua-s Model Development Workflow Gene Expression Mammalian Blastocyst.pdf]]
  • [get | view] (2017-07-30 14:29:04, 29702.4 KB) [[attachment:Monday lectures Python ppt and code.zip]]
  • [get | view] (2017-08-02 19:58:27, 58286.7 KB) [[attachment:MultiScaleModelingWithCC3D-SBML.pptx]]
  • [get | view] (2017-08-01 18:49:13, 7433.6 KB) [[attachment:PBPK_SBML_modeling.pptx]]
  • [get | view] (2017-07-31 21:35:05, 38.2 KB) [[attachment:PK_simple_one_compartment.cps]]
  • [get | view] (2017-07-30 19:38:10, 738.3 KB) [[attachment:Priyom Verbal Model from Mark Alber Epithelial paper with annotations.docx]]
  • [get | view] (2017-07-27 15:34:10, 113.2 KB) [[attachment:PythonRefCard_1p.pdf]]
  • [get | view] (2017-07-27 15:34:51, 1634.3 KB) [[attachment:PythonRefCard_8p.pdf]]
  • [get | view] (2017-07-31 17:20:59, 19455.7 KB) [[attachment:Slides_ReactionKinetics-2.pptx]]
  • [get | view] (2017-07-30 17:31:42, 97.3 KB) [[attachment:WP_20170730_13_29_10_small.jpg]]
  • [get | view] (2017-07-31 18:01:31, 118.2 KB) [[attachment:WP_20170731_13_10_15_Pro.jpg]]
  • [get | view] (2017-07-27 16:27:11, 36.5 KB) [[attachment:beginners_python_cheat_sheet_pcc_SELECTED.png]]
  • [get | view] (2017-08-04 17:40:39, 13.1 KB) [[attachment:cellcycle_DN.zip]]
  • [get | view] (2017-08-04 17:47:09, 92.6 KB) [[attachment:class_photo.jpg]]
  • [get | view] (2017-08-02 19:59:01, 34.5 KB) [[attachment:delta-notch.cps]]
  • [get | view] (2017-08-02 20:05:06, 987.6 KB) [[attachment:delta-notch.pptx]]
  • [get | view] (2017-08-04 17:20:05, 5.8 KB) [[attachment:gradient_1.zip]]
  • [get | view] (2017-08-04 17:20:14, 6.9 KB) [[attachment:gradient_2.zip]]
  • [get | view] (2017-08-04 17:20:24, 6.6 KB) [[attachment:gradient_3.zip]]
  • [get | view] (2017-07-28 21:48:18, 3377.8 KB) [[attachment:holmes_et_al.gene_exp_enh_blas.pdf]]
  • [get | view] (2017-07-28 21:48:28, 2700.3 KB) [[attachment:holmes_sup_material.pdf]]
  • [get | view] (2017-07-31 13:25:51, 18008.4 KB) [[attachment:journal.pcbi.1005533.pdf]]
  • [get | view] (2017-07-30 14:57:48, 921.2 KB) [[attachment:lec1-intro.pptx]]
  • [get | view] (2017-07-30 14:57:40, 1.2 KB) [[attachment:lec1.py]]
  • [get | view] (2017-07-30 14:58:39, 76.8 KB) [[attachment:lec2-branching-iteration.pptx]]
  • [get | view] (2017-07-30 14:57:55, 2.8 KB) [[attachment:lec2.py]]
  • [get | view] (2017-07-30 14:58:57, 61.3 KB) [[attachment:lec3-strings-approximations.pptx]]
  • [get | view] (2017-07-30 14:58:46, 2.9 KB) [[attachment:lec3.py]]
  • [get | view] (2017-07-30 14:59:04, 1342.3 KB) [[attachment:lec4-basic-functions.pptx]]
  • [get | view] (2017-07-30 14:59:23, 2097.2 KB) [[attachment:lec5-tuple-lists.pdf]]
  • [get | view] (2017-07-30 14:59:15, 4.5 KB) [[attachment:lec5_tuples_lists.py]]
  • [get | view] (2017-07-30 14:59:47, 287.6 KB) [[attachment:lec6-dictionaries.pptx]]
  • [get | view] (2017-07-30 14:59:28, 4.6 KB) [[attachment:lec6.py]]
  • [get | view] (2017-07-30 14:59:39, 4.6 KB) [[attachment:lec6_recursion_dictionaries.py]]
  • [get | view] (2017-07-30 14:59:58, 20274.9 KB) [[attachment:lec7-random-walk.pptx]]
  • [get | view] (2017-08-09 16:50:37, 584.2 KB) [[attachment:parameter-scan.pdf]]
  • [get | view] (2017-07-27 16:26:57, 31.3 KB) [[attachment:python_refcard.png]]
  • [get | view] (2017-08-01 18:56:32, 3390.1 KB) [[attachment:s13628-015-0022-x.pdf]]
  • [get | view] (2017-07-28 18:54:30, 22.2 KB) [[attachment:schedule.docx]]
  • [get | view] (2017-07-28 18:54:20, 301.5 KB) [[attachment:schedule.pdf]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.