diff --git a/cs171/Lect05/minmax.py b/cs171/Lect05/minmax.py new file mode 100644 index 0000000000000000000000000000000000000000..5235576839ae6f188c094e8228aff605abc79a38 --- /dev/null +++ b/cs171/Lect05/minmax.py @@ -0,0 +1,17 @@ + + +# Given a list of integer values, write Python code +# using a for loop and range to sum the values in the list. +# +# Then, confirm that your code results in the same answer +# as sum() + +nums = [8, 6, 7, 5, 3, 0, 9] + +myAnswer = nums[0] +for index in range(0, len(nums)): + value = nums[index] + if value < myAnswer: + myAnswer = value + +print(myAnswer == min(nums)) #?? \ No newline at end of file diff --git a/cs171/Lect05/nested.py b/cs171/Lect05/nested.py new file mode 100644 index 0000000000000000000000000000000000000000..e958502afe84042913bc581893e045e625ff5393 --- /dev/null +++ b/cs171/Lect05/nested.py @@ -0,0 +1,4 @@ + +for i in range(1, 5): + for j in range(1, 3): + print(i,j) \ No newline at end of file diff --git a/cs171/Lect05/range.py b/cs171/Lect05/range.py new file mode 100644 index 0000000000000000000000000000000000000000..20a22fbb2128613899df8e6c1cbcc5ffc04f1bed --- /dev/null +++ b/cs171/Lect05/range.py @@ -0,0 +1,8 @@ + +# for letter in "Hello": +# print(letter) + +for i in range(1, 10): + print(i) + + diff --git a/cs171/Lect05/splitjoin.py b/cs171/Lect05/splitjoin.py new file mode 100644 index 0000000000000000000000000000000000000000..c8a9fb4248f047b17cc12b009072e745e7d74416 --- /dev/null +++ b/cs171/Lect05/splitjoin.py @@ -0,0 +1,12 @@ + + +text = "127.0.0.1" +parts = text.split(".") +together = "[DOT]".join(parts) +print(together) + +# vals = [10, 20, [30, 40], [50, 60, 70]] +# +# print(len(vals)) +# for val in vals: +# print(val) \ No newline at end of file diff --git a/cs171/Lect05/tinker.py b/cs171/Lect05/tinker.py new file mode 100644 index 0000000000000000000000000000000000000000..a3262829588e412203d1125d2f366e049068f341 --- /dev/null +++ b/cs171/Lect05/tinker.py @@ -0,0 +1,12 @@ +value = 17 +values = [3, 1, 4, 1, 5, 9] +word = "Dragon" +letters = list(word) #str(), int(), float(), list() + +myDigits = [0, 0, 1, 1, 0, 0] +yourDigits = list(myDigits) +yourDigits[0] = 99 + +print(word) +print(letters) +print(yourDigits)