Last active
July 20, 2020 02:01
-
-
Save misterhtmlcss/ae9c229428f198d20b9245ee4bdc4d33 to your computer and use it in GitHub Desktop.
Revisions
-
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -128,5 +128,4 @@ def test_lowercase_list(funcs): Reference Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tree Press. Hunner, T. (2016). "How to loop with indexes in Python". Retrieved from https://treyhunner.com/2016/04/how-to-loop-with-indexes-in-python/ """ -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 22 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -95,40 +95,38 @@ def test_lowercase_list(funcs): # ************************** # OUTPUT # ************************** # 0** Roger: <function any_lowercase1 at 0x7f983f5b91f0> False # 0** oger: <function any_lowercase1 at 0x7f983f5b91f0> True # 0** rogeR: <function any_lowercase1 at 0x7f983f5b91f0> True # 1** Roger: <function any_lowercase2 at 0x7f9840921820> True # 1** oger: <function any_lowercase2 at 0x7f9840921820> True # 1** rogeR: <function any_lowercase2 at 0x7f9840921820> True # 2** Roger: <function any_lowercase3 at 0x7f98409218b0> True # 2** oger: <function any_lowercase3 at 0x7f98409218b0> True # 2** rogeR: <function any_lowercase3 at 0x7f98409218b0> False # 3** Roger: <function any_lowercase4 at 0x7f9840921940> True # 3** oger: <function any_lowercase4 at 0x7f9840921940> True # 3** rogeR: <function any_lowercase4 at 0x7f9840921940> True # 4** Roger: <function any_lowercase5 at 0x7f98409219d0> False # 4** oger: <function any_lowercase5 at 0x7f98409219d0> True # 4** rogeR: <function any_lowercase5 at 0x7f98409219d0> False # ************************** # Reference # ************************** """ Reference Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tree Press. Hunner, T. (2016). "How to loop with indexes in Python". Retrieved from https://treyhunner.com/2016/04/how-to-loop-with-indexes-in-python/ """ -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 11 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,15 @@ # ************************** # CS1101 - Discussion Unit 5 # ************************** # ************************** # Instructions # 1. Check whether its argument has any lowercase letters # 2. Describe what it actually does when called with a string argument and if it does not correctly check for lowercase letters. # 4. Give an example argument that produces incorrect results. (SEE BOTTOM for 3 calls to all functions!) # 5. Describe why the result is incorrect. (SEE inline comments) # ************************** # ************************** -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,6 +12,7 @@ ************************** """ # ************************** # Decides on the first letter and breaks the for..in loop once it's True or False # Roger == False, because of R, @@ -24,6 +25,7 @@ def any_lowercase1(s): else: return False # ************************** # 'c' is a string. It is passing a string not c the variable, which means it's always true, because 'c' is lowercase. def any_lowercase2(s): @@ -52,6 +54,7 @@ def any_lowercase4(s): flag = flag or c.islower() return flag # ************************** # Will check if string has an uppercase and when True, then break the for..in loop with a False. def any_lowercase5(s): -
misterhtmlcss revised this gist
Jul 20, 2020 . No changes.There are no files selected for viewing
-
misterhtmlcss revised this gist
Jul 20, 2020 . No changes.There are no files selected for viewing
-
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -85,10 +85,11 @@ def test_lowercase_list(funcs): # This function iterates over all the functions from list_funcs test_lowercase_list(list_funcs) # ************************** # ************************** # ************************** # ************************** # OUTPUT # ************************** -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -90,10 +90,9 @@ def test_lowercase_list(funcs): # ************************** # ************************** # ************************** # OUTPUT # ************************** """ 0** Roger: <function any_lowercase1 at 0x7f983f5b91f0> False 0** oger: <function any_lowercase1 at 0x7f983f5b91f0> True 0** rogeR: <function any_lowercase1 at 0x7f983f5b91f0> True -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -87,6 +87,9 @@ def test_lowercase_list(funcs): test_lowercase_list(list_funcs) # ************************** # ************************** # ************************** """ ************************** OUTPUT -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -68,7 +68,7 @@ def any_lowercase5(s): # ************************** # Program manager # Runs all the functions with the test strings in series and prints them. # ************************** def test_lowercase_list(funcs): #i when, func what is called, func('xxx') results printed -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -63,6 +63,7 @@ def any_lowercase5(s): return True # ************************** # ************************** # ************************** # ************************** -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -61,9 +61,14 @@ def any_lowercase5(s): return False # All iterations succeed without a return and then the function exits the for..in and returns True. return True # ************************** # ************************** # ************************** # Program manager # Runs all the functions with the same print series # ************************** def test_lowercase_list(funcs): #i when, func what is called, func('xxx') results printed for i, func in enumerate(funcs): # (Hunner, T., 2016) @@ -73,6 +78,7 @@ def test_lowercase_list(funcs): print(f'{i}** rogeR:', func, func('rogeR')) print('\n') # ************************** # list of functions above list_funcs = [any_lowercase1, any_lowercase2, any_lowercase3, any_lowercase4, any_lowercase5] -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 14 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,8 @@ ************************** """ # ************************** # Decides on the first letter and breaks the for..in loop once it's True or False # Roger == False, because of R, # oger == True, because of o # ogeR == True, because of o; doesn't keep looking. @@ -23,7 +24,8 @@ def any_lowercase1(s): else: return False # ************************** # 'c' is a string. It is passing a string not c the variable, which means it's always true, because 'c' is lowercase. def any_lowercase2(s): for c in s: # Lowercase is true every time. @@ -32,21 +34,26 @@ def any_lowercase2(s): else: return 'False' # ************************** # A. 'flag' (inner variable) is declared inside the scope of the for..in loop and it's scope doesn't extend to the parent scope of the function. # B. name 'flag' (outer variable) is not defined. It's irrelevant. def any_lowercase3(s): for c in s: flag = c.islower() return flag # ************************** # Once the `flag` is found to be True it can't be reassigned. First 'truth' means all are True. def any_lowercase4(s): flag = False for c in s: flag = flag or c.islower() return flag # ************************** # Will check if string has an uppercase and when True, then break the for..in loop with a False. def any_lowercase5(s): for c in s: # Iterates continuously inside this loop until the return False on any single uppercase @@ -55,7 +62,7 @@ def any_lowercase5(s): # All iterations succeed without a return and then the function exits the for..in and returns True. return True # ************************** # Runs all the functions with the same print series def test_lowercase_list(funcs): #i when, func what is called, func('xxx') results printed -
misterhtmlcss revised this gist
Jul 20, 2020 . No changes.There are no files selected for viewing
-
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,10 +3,13 @@ CS1101 - Discussion Unit 5 ************************** ************************** Instructions 1. Check whether its argument has any lowercase letters 2. Describe what it actually does when called with a string argument and if it does not correctly check for lowercase letters. 4. Give an example argument that produces incorrect results. (SEE BOTTOM for 3 calls to all functions!) 5. Describe why the result is incorrect. (SEE inline comments) ************************** """ # 1: Decides on the first letter and breaks the for..in loop once it's True or False @@ -71,8 +74,9 @@ def test_lowercase_list(funcs): """ ************************** OUTPUT ************************** 0** Roger: <function any_lowercase1 at 0x7f983f5b91f0> False 0** oger: <function any_lowercase1 at 0x7f983f5b91f0> True 0** rogeR: <function any_lowercase1 at 0x7f983f5b91f0> True @@ -97,8 +101,9 @@ def test_lowercase_list(funcs): 4** oger: <function any_lowercase5 at 0x7f98409219d0> True 4** rogeR: <function any_lowercase5 at 0x7f98409219d0> False ************************** Reference ************************** Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tree Press. Hunner, T. (2016). "How to loop with indexes in Python". Retrieved from https://treyhunner.com/2016/04/how-to-loop-with-indexes-in-python/ -
misterhtmlcss revised this gist
Jul 20, 2020 . No changes.There are no files selected for viewing
-
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,8 @@ """ ************************** CS1101 - Discussion Unit 5 ************************** 1. Check whether its argument has any lowercase letters 2. Describe what it actually does when called with a string argument and if it does not correctly check for lowercase letters. 4. Give an example argument that produces incorrect results. (SEE BOTTOM for 3 calls to all functions!) -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -92,12 +92,15 @@ def test_lowercase_list(funcs): 4** Roger: <function any_lowercase5 at 0x7f98409219d0> False 4** oger: <function any_lowercase5 at 0x7f98409219d0> True 4** rogeR: <function any_lowercase5 at 0x7f98409219d0> False Reference Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tree Press. Hunner, T. (2016). "How to loop with indexes in Python". Retrieved from https://treyhunner.com/2016/04/how-to-loop-with-indexes-in-python/ """ -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -65,7 +65,10 @@ def test_lowercase_list(funcs): # This function iterates over all the functions from list_funcs test_lowercase_list(list_funcs) """ OUTPUT 0** Roger: <function any_lowercase1 at 0x7f983f5b91f0> False 0** oger: <function any_lowercase1 at 0x7f983f5b91f0> True 0** rogeR: <function any_lowercase1 at 0x7f983f5b91f0> True -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 29 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -65,8 +65,36 @@ def test_lowercase_list(funcs): # This function iterates over all the functions from list_funcs test_lowercase_list(list_funcs) """ 0** Roger: <function any_lowercase1 at 0x7f983f5b91f0> False 0** oger: <function any_lowercase1 at 0x7f983f5b91f0> True 0** rogeR: <function any_lowercase1 at 0x7f983f5b91f0> True 1** Roger: <function any_lowercase2 at 0x7f9840921820> True 1** oger: <function any_lowercase2 at 0x7f9840921820> True 1** rogeR: <function any_lowercase2 at 0x7f9840921820> True 2** Roger: <function any_lowercase3 at 0x7f98409218b0> True 2** oger: <function any_lowercase3 at 0x7f98409218b0> True 2** rogeR: <function any_lowercase3 at 0x7f98409218b0> False 3** Roger: <function any_lowercase4 at 0x7f9840921940> True 3** oger: <function any_lowercase4 at 0x7f9840921940> True 3** rogeR: <function any_lowercase4 at 0x7f9840921940> True 4** Roger: <function any_lowercase5 at 0x7f98409219d0> False 4** oger: <function any_lowercase5 at 0x7f98409219d0> True 4** rogeR: <function any_lowercase5 at 0x7f98409219d0> False """ # Reference # Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tree Press. # Hunner, T. (2016). "How to loop with indexes in Python". Retrieved from https://treyhunner.com/2016/04/how-to-loop-with-indexes-in-python/ -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ 1. Check whether its argument has any lowercase letters 2. Describe what it actually does when called with a string argument and if it does not correctly check for lowercase letters. 4. Give an example argument that produces incorrect results. (SEE BOTTOM for 3 calls to all functions!) 5. Describe why the result is incorrect. (SEE inline comments) """ # 1: Decides on the first letter and breaks the for..in loop once it's True or False -
misterhtmlcss revised this gist
Jul 20, 2020 . No changes.There are no files selected for viewing
-
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ 1. Check whether its argument has any lowercase letters 2. Describe what it actually does when called with a string argument and if it does not correctly check for lowercase letters. 4. Give an example argument that produces incorrect results. (SEE BOTTOM for 3 calls to all functions!) 5. Describe why the result is incorrect. (SEE INLINE COMMENTS) """ # 1: Decides on the first letter and breaks the for..in loop once it's True or False -
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -63,7 +63,7 @@ def test_lowercase_list(funcs): list_funcs = [any_lowercase1, any_lowercase2, any_lowercase3, any_lowercase4, any_lowercase5] # This function iterates over all the functions from list_funcs test_lowercase_list(list_funcs) -
misterhtmlcss revised this gist
Jul 20, 2020 . No changes.There are no files selected for viewing
-
misterhtmlcss revised this gist
Jul 20, 2020 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,8 @@ """ 1. Check whether its argument has any lowercase letters 2. Describe what it actually does when called with a string argument and if it does not correctly check for lowercase letters. 4. Give an example argument that produces incorrect results. (SEE BOTTOM for 3 calls to all functions!) 5. Describe why the result is incorrect. """ # 1: Decides on the first letter and breaks the for..in loop once it's True or False -
misterhtmlcss created this gist
Jul 20, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ """ 1. Check whether its argument has any lowercase letters 2. describe what it actually does when called with a string argument 3. If it does not correctly check for lowercase letters, give an example argument that produces incorrect results, and describe why the result is incorrect. """ # 1: Decides on the first letter and breaks the for..in loop once it's True or False # Roger == False, because of R, # oger == True, because of o # ogeR == True, because of o; doesn't keep looking. def any_lowercase1(s): for c in s: if c.islower(): return True else: return False # 2: 'c' is a string. It is passing a string not c the variable, which means it's always true, because 'c' is lowercase. def any_lowercase2(s): for c in s: # Lowercase is true every time. if 'c'.islower(): return 'True' else: return 'False' # 3a. 'flag' (inner variable) is declared inside the scope of the for..in loop and it's scope doesn't extend to the parent scope of the function. # 3b. name 'flag' (outer variable) is not defined. It's irrelevant. def any_lowercase3(s): for c in s: flag = c.islower() return flag # 4: Once the `flag` is found to be True it can't be reassigned. First 'truth' means all are True. def any_lowercase4(s): flag = False for c in s: flag = flag or c.islower() return flag # 5 Will check if string has an uppercase and when True, then break the for..in loop with a False. def any_lowercase5(s): for c in s: # Iterates continuously inside this loop until the return False on any single uppercase if not c.islower(): return False # All iterations succeed without a return and then the function exits the for..in and returns True. return True # Runs all the functions with the same print series def test_lowercase_list(funcs): #i when, func what is called, func('xxx') results printed for i, func in enumerate(funcs): # (Hunner, T., 2016) # prints index number with string test, function and function call result. print(f'{i}** Roger:', func, func('Roger')) print(f'{i}** oger:', func, func('ogerc')) print(f'{i}** rogeR:', func, func('rogeR')) print('\n') # list of functions above list_funcs = [any_lowercase1, any_lowercase2, any_lowercase3, any_lowercase4, any_lowercase5] # This function iterates over all the functions from list_funcs print('funcs working? ', test_lowercase_list(list_funcs)) # Reference # Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tree Press. # Hunner, T. (2016). "How to loop with indexes in Python". Retrieved from https://treyhunner.com/2016/04/how-to-loop-with-indexes-in-python/