Data types and casting
Head over to Section 3 on the CSNEWBS website. Work through the examples and challenges before coming back to watch the video and take the knowledge check.
Now watch the video . Take notes.
Now take the test
Programming task
Below is a program that removes duplicate (repeated) values from a list and then prints out the list, without the duplicates.
A sub-program is used to find and remove the duplicates.
Your task is to run the program AND to add comments to EVERY line explaining the purpose of the line. Copy and paste the code below into a Thonny or online-python file, then share or upload it to me.
A sub-program is used to find and remove the duplicates.
Your task is to run the program AND to add comments to EVERY line explaining the purpose of the line. Copy and paste the code below into a Thonny or online-python file, then share or upload it to me.
The code
nums = [3,5,6,5,7,3,8,9,2,3,6] #
def remove_duplicates(PnumsIn): # nums2 = [] # for item in PnumsIn: # if item not in nums2: # nums2.append(item) # return nums2 # no_duplicates = (remove_duplicates(nums)) # print(no_duplicates) # |
|