jspill

webinar-python-exam-review-2022-10-29

Oct 29th, 2022
2,426
0
Never
5
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.00 KB | None | 0 0
  1. # Exam Review 2022 Oct 29
  2.  
  3. # LABS
  4. # Ch 2-14... all Labs!
  5. # Ch 21-33 just ADDITIONAL LABS, but important practice!
  6. # Use Submit Mode!!!
  7.  
  8. # Watch your string input and output
  9. # # 1
  10. # myVar = input().strip() # myVar = input().rstrip()
  11. # # 2
  12. # print("some stuff", end=" ") # if you ever override end
  13. # print() # print(end="\n")
  14.  
  15. # print("Clean new line!")
  16.  
  17. # # Comp 1: Basic syntax and knowledge: operators, data types, etc
  18. # # Comp 2: Control Flow
  19. # # Comp 3: Modules and Files
  20.  
  21. # # Comp 1: Basic syntax and knowledge: operators, data types, etc
  22. # operators
  23. # = # assigns
  24. # == # "equality operator", comparison... if/elif, while
  25. # +
  26. # -
  27. # *
  28. # /
  29. # % # modulo, int remainder... "how many left over?"
  30. # // # floor division... x//y -> math.floor(x/y)... for positive numbers int(x/y)
  31. # <
  32. # >
  33. # <=
  34. # >=
  35. # += # increment... x+=1 --> x = x+1
  36. # -= # decrement
  37. # !=
  38. # ** # raising to a power, similar to math.pow()
  39. # # keywords
  40. # in # if _someValue_ in _someContainer_
  41. # not # if not _someValue_ in _someContainer_
  42. # and
  43. # or # any one True means whole condition is True... limit OR to 2 conditions
  44.  
  45. # Common Data Types
  46. # str # ""
  47. # int
  48. # float
  49. # list # []
  50. # dict # {key: value}
  51. # set # {} no order, all unique values
  52. # tuple # () immutable... Python sees any x,y,z as (x,y,z)... return x,y -> return (x,y)
  53.  
  54. # Comp 2
  55. # # the HOW stuff... control flow structures
  56. # IF statements... if, if/else, if/elif/else...
  57. # LOOPS
  58. # WHILE - an IF that repeats
  59. # FOR - looping over a container, or a known of times... range()
  60. # for _item_ in _container_:
  61. # for item in myList:
  62. # for n in range(0, 5): # [0, 1, 2, 3, 4]
  63. # for i in range(0, len(myList)): # myList[i]
  64. # for key in myDictionary: # myDictionary[key] is that key's value
  65.  
  66. # FUNCTIONS
  67. # defining/writing vs calling
  68. # parameters are special "variables"... they don't work like "regular" variables
  69. # parameters vs arguments
  70. # a function has ONE particular job
  71. # return vs print()... writes a file... whatever the question says
  72. # method are functions that belong to a particular type/class
  73.  
  74. # def someFunction(x, y):
  75. #     return x + y
  76. #
  77. # if __name__ == "__main__":
  78. #     myInput = int(input())
  79. #     myOtherInput = int(input())
  80. #     num = someFunction(myInput, myOtherInput)
  81. #     print(num)
  82. #     # print(someFunction(myInput, myOtherInput))
  83.  
  84. # See "tasks" in the last section of Ch 10, 11, 13, 14 for function writing practice
  85. # # CodingBat also has good function-based Python questions:
  86. # # https://codingbat.com/python
  87.  
  88. # # BUILT-IN FUNCTIONS
  89. # print()
  90. # input()
  91. # type() # print(type("5").__name__)
  92. # range()
  93. # len()
  94. # sum()
  95. # min()
  96. # max()
  97. # round() # but its cousins math.ceil() and math.floor() are in the math
  98. # open() # IO/file .read(), .readlines(), .write()
  99. #
  100. # reversed() # return reversed list... compare to list.reverse() does not return
  101. # sorted() # return sorted list... compare to list.sort() does not return
  102.  
  103. #
  104. # # constructor functions
  105. # str()
  106. # list()
  107. # int()
  108. # float()
  109. # dict()
  110. # set()
  111.  
  112. # our favorites?
  113. # help() # help(str), help(str.isdigit)
  114. # dir() # print(dir(str))
  115.  
  116. # STRINGS
  117. # be able to slice like it's 2nd nature: myString[start:stop:step]
  118. # myString = "abc"
  119. # revString = myString[::-1]
  120. # print(revString)
  121.  
  122. # KNOW YOUR WHITESPACE
  123. # " " # ... and a lot of other Unicode spaces
  124. # "\n"
  125. # "\r"
  126. # "\t"
  127. # "\f"
  128.  
  129. # STRING METHODS
  130. # "stuff I want to put together {}".format(var) # or similar f strings
  131. # myString.strip() # input().strip()
  132. # myString.split() # returns a list of smaller strings
  133. # ",".join(listOfStrings)
  134. # myString.replace(oldSubStr, newSubStr) # remove... myString.replace(subStr, "")
  135. # myString.find(subStr) # returns int index, or -1
  136. # myString.count(subStr) # return int count of num occurrences
  137. # case: myString.lower(), myString.upper(), myString.title()
  138. # is/Boolean: isupper(), islower(), isalpha(), isdigit(), isalnum(), isspace()
  139.  
  140. # LISTS
  141. # again be to slice
  142.  
  143. # LIST METHODS
  144. # +
  145. # myList.append(item)
  146. # myList.insert(i, item)
  147. # myList.extend(anotherList)
  148. # # -
  149. # myList.pop() # myList.pop(i)... pop() by INDEX
  150. # myList.remove(item) # remove() by VALUE
  151. # # other mods
  152. # myList.count(item) # returns number
  153. # myList.sort()
  154. # myList.reverse()
  155. # # also rans
  156. # myList.clear()
  157. # myList.copy()
  158. # myList.index(item)
  159.  
  160. # DICT
  161. # use the key like an index
  162. # # myDict[key] # retrieve the value for that key, so like get()
  163. # # myDict[key] = value # assign (new) value for that key, so like update({k:v})
  164. # myDict.keys()
  165. # myDict.values()
  166. # myDict.items() # for k, v in myDict.items()... x, y = [2, 8]
  167.  
  168. # # MODULES
  169. # # math and csv
  170. # # remember there are different import styles that change how you reference them
  171.  
  172. # MATH MODULE
  173. # import math
  174. # math.factorial(x)
  175. # math.ceil(x.yz)
  176. # math.floor(x.zy)
  177. # math.pow(x, y) # similar to **, not be confused with math.exp()
  178. # math.sqrt(x)
  179. # math.fabs() # similar to built-in abs()
  180. # math.pi
  181. # math.e
  182.  
  183. # PARTIAL IMPORT
  184. # from math import factorial
  185. # don't say math.factorial()... we didn't import math
  186. # factorial() # Drake points appreciately
  187.  
  188. # # ALIAS IMPORT
  189. # # import math as m --> m.floor(), etc
  190.  
  191. # FILES!!!
  192. # with open("test.txt", "r") as f:
  193. #     contents = f.readlines() # a list of line by line str
  194. # # print(contents)
  195. # for line in contents:
  196. #     line = line.strip()
  197. #     print(line) # print(line, end="\n")
  198.  
  199. # CSV
  200. # import csv
  201. # with open("mock_data.csv", "r") as f1:
  202. #     contents = list(csv.reader(f1)) # csv.reader(f1, delimiter="\t")
  203. # print(contents) # ['7', 'Isidor', 'Hogben', '[email protected]', 'Male', '40.219.108.2']
  204. #
  205. # with open("output_data6.csv", "w") as f2:
  206. #     for line in contents:
  207. #         if line[3][-4:] == ".edu":
  208. #             # the write() method takes a SINGLE string as its arg
  209. #             f2.write(",".join(line)+"\n")
  210. #             # f2.write("{}{}".format(",".join(line), "\n")) # or...
  211. #             # f2.write(f"{','.join(line)}{'\n'}")
  212.  
  213.  
  214. # append mode
  215. with open("append_to_this.txt", "a") as f3:
  216.     f3.write("Pippin\n")
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
Advertisement
Comments
  • DavidDepape
    3 years
    Comment was deleted
  • DavidDepape
    3 years
    # text 1.26 KB | 0 0
    1. 27Oct2022_12:48 227b..1977 wooooshhhhh!!!!
    2. 27Oct2022_12:00 e33f..de19 https://kaildganglife.blogspot.com/2011/03/prison-gangs-one-mexican-mafia-v.html
    3. 27Oct2022_11:59 4723..b8fc kaildganglife.blogspot.com/2011/04/prison-gangs-two-black-guerilla-family.html
    4. 27Oct2022_11:56 c17b..026d https://albertsmithirishindependentnewspaper.loforo.com/
    5. 27Oct2022_11:56 033a..687b https://kiearanconwaysolicitors.loforo.com/
    6. 27Oct2022_11:55 fe7f..f013 https://wikileaksworldvapour.loforo.com/
    7. 27Oct2022_10:55 eec6..b073 kiearanconwaysolicitors – Loforo
    8. 27Oct2022_10:54 5fb7..3573 https://kieranconwaysolicitors.loforo.com/
    9. 27Oct2022_10:54 a84b..4800 https://wikifreaks-wikifreaks3.loforo.com/
    10. 27Oct2022_10:53 41f1..2279 https://wikifreaks-wikifreaks2.loforo.com/
    11. 27Oct2022_10:53 3d53..b7f8 https://wikifreaks-wikifreaks1.loforo.com/
    12. 27Oct2022_10:52 2015..5334 https://wikifreaks-wikifreaks.loforo.com/
    13. 27Oct2022_10:51 9938..b81c https://wikifreaksworldvision.loforo.com/
    14. 27Oct2022_10:51 7532..b464 https://wikifreaks2.loforo.com/
    15. 27Oct2022_10:50 5b2a..d6e5 https://wikifreaks1.loforo.com/
    16. 27Oct2022_10:50 c123..c4dc https://wikifreaks.loforo.com/
    17. 27Oct2022_10:46 0120..ac11 http://www.darkpolitricks.com/2022/10/liz-truss-green-screen-zelenskyy-and.html
  • DavidDepape
    3 years
    # text 0.82 KB | 0 0
    1. 27Oct2022_08:31 0a6d..fe18 http://paste.org.ru/?em7tj8 Dr Moayyad Al Kamali spy allegations
    2. 26Oct2022_19:40 fb9d..0495 https://kieranconwaysolicitors.loforo.com/
    3. 26Oct2022_19:33 c30d..d797 https://thumbsnap.com/i/FVqKPoEx.jpg
    4. 26Oct2022_19:32 5921..2142 https://thumbsnap.com/i/21bqPREE.jpg
    5. 26Oct2022_19:32 59b4..696f https://thumbsnap.com/i/xCRUA7Bz.png
    6. 26Oct2022_19:31 3285..c1db https://thumbsnap.com/i/FH8GBaqv.png
    7. 26Oct2022_19:31 998a..2ff5 https://thumbsnap.com/i/2uJY3EW3.png
    8. 26Oct2022_19:30 ca14..c2b7 https://thumbsnap.com/i/GBxGDwYY.jpg
    9. 26Oct2022_19:30 d01e..5ea9 https://thumbsnap.com/i/Z1mLdoCf.jpg
    10. 26Oct2022_19:29 612b..138f https://thumbsnap.com/i/9MAUt76K.png
    11. 26Oct2022_19:29 d1df..c884 https://thumbsnap.com/i/qMWBtDD6.jpg
    12. 26Oct2022_19:28 41f8..cf76 https://thumbsnap.com/i/jQVgcjhp.jpg
  • DavidDepape
    3 years
    # text 2.13 KB | 0 0
    1. 23Oct2022_14:41 9c8c..867c http://www.darkpolitricks.com/2020/11/well-done-america-you-voted-for-what.html
    2. 23Oct2022_14:33 5bbe..b345 www.darkpolitricks.com/2020/04/well-it-seems-google-really-didnt-like.html
    3. 23Oct2022_14:32 ed42..e2c8 http://www.darkpolitricks.com/2018/07/israel-is-first-terrorist-state-with.html
    4. 23Oct2022_14:31 b296..0668 http://www.darkpolitricks.com/2021/05/cia-agent-admits-why-usa-cant-have.html
    5. 23Oct2022_14:07 4f95..d812 http://www.darkpolitricks.com/2020/04/help-me-create-real-altnews-search.html
    6. 23Oct2022_14:06 36c5..f4bb http://www.darkpolitricks.com/2020/07/covid19-were-loving-it.html
    7. 23Oct2022_13:45 2b4e..5780 www.darkpolitricks.com/2022/04/who-are-we-standing-with-when-we-stand.html
    8. 23Oct2022_13:44 8483..08e3 http://www.darkpolitricks.com/2022/03/the-stupidity-of-russian-sanctions.html
    9. 23Oct2022_13:42 16a2..10a5 www.darkpolitricks.com/2022/01/how-many-conspiracies-have-to-turn-true.html
    10. 23Oct2022_13:41 a486..74ba darkpolitricks.com/2021/09/the-uk-is-becoming-more-despotic-every.html
    11. 23Oct2022_13:40 4605..9f8e http://www.darkpolitricks.com/2021/12/the-internet-is-dead-can-you-prove-it.html
    12. 23Oct2022_13:35 e899..f184 http://www.darkpolitricks.com/2022/03/two-things-can-be-right-at-same-time.html
    13. 23Oct2022_13:28 d629..79a9 http://www.darkpolitricks.com/2021/03/is-biden-worse-than-trump.html
    14. 23Oct2022_13:27 8885..6d01 http://www.darkpolitricks.com/2022/05/here-comes-world-war-iii.html
    15. 23Oct2022_13:26 6692..546b http://www.darkpolitricks.com/2020/02/am-i-going-down-google-plug-of.html
    16. 23Oct2022_13:02 c9ef..99d3 wooooshhhhh!!!!
    17. 23Oct2022_13:01 32e5..289f https://0000001.onepage.website/
    18. 23Oct2022_12:40 7fea..56ca wooooshhhhh!!!!
    19. 23Oct2022_12:39 27ba..e21f DICE https://images4.imagebam.com/26/a0/30/MEDWGTV_o.jpeg
    20. 23Oct2022_12:39 8db8..1808 DICE https://images4.imagebam.com/fb/ef/3f/MEDWGTZ_o.jpeg
    21. 23Oct2022_12:38 acfb..a06d DICE https://images4.imagebam.com/ea/ea/7d/MEDWGU3_o.jpeg
    22. 23Oct2022_12:36 fa9d..9191 DICE https://images4.imagebam.com/ef/59/32/MEDWGUA_o.jpeg
    23. 23Oct2022_12:31 f86d..4195 You having fun?
    24. 23Oct2022_12:20 3ea8..708c wooooshhhhh!!!!
  • DavidDepape
    3 years
    Comment was deleted
Add Comment
Please, Sign In to add comment