<jupyter_start><jupyter_text>Questions **1. To clarify, are the main differences between a set and a list simply (1) a set does not have repeats whilst a list can, and (2) sets are unordered whereas lists are?** **Answer:** The short answer is **Yes**!**List**, **tuple** and **set** are three data types in Python that are often compared to each other by people.* `List` is a **mutable**, **ordered** collections of elements* `Tuple` is a **immutable**, **ordered** collections of elements* `set` is a **unordered** collections of **unique** elementsNote: since `set` is unordered, and one cannot access its elements by using indexing. Therefore, it doesn't make sense to say a `set` is mutable or immutable.<jupyter_code># Here we define two sets
dataScientist = set(['Python', 'R', 'SQL', 'Git', 'Tableau', 'SAS'])
dataEngineer = set(['Python', 'Java', 'Scala', 'Git', 'SQL', 'Hadoop'])
print(dataScientist)
print(dataEngineer)<jupyter_output>{'SQL', 'Hadoop', 'Git', 'Python', 'Scala', 'Java'}<jupyter_text>As you can see, the stored values in the set are not in the order they are added in. That is why we say `set` is unordered, and of course, you cannot access the element using indexing.<jupyter_code>dataScientist[1]<jupyter_output><empty_output><jupyter_text>One of the benefits of using `set` is that you can remove redundant elements from a list through the `set` data type.<jupyter_code>mylist = [1, 2, 1, 1, 4, 3, 7, 6, 9, 5, 1, 2, 5, 3, 2, 7, 8, 9, 1, 2, 3, 5]
mylist_NoRedundant = list(set(mylist))
print(mylist_NoRedundant)<jupyter_output>[1, 2, 3, 4, 5, 6, 7, 8, 9]<jupyter_text>And such an operation is usually fast in calculation. For more information of `set` please refer to: [Python Sets and Set Theory](https://www.datacamp.com/community/tutorials/sets-in-python) --- **2. I was wondering if the following input could be shortened or simplified:** ![](../materials/images/q1.png) **Answer:**First, the solution is right, good work!Making the code consice is a good habit, especially when you are working on a huge project with tens of thousands lines of code. Return to your code, there are several places that can be simplified.* The converted data do not really need to be stored (assigned) to a variable, even if you use the same variable.* The addition operation and data type conversion can be implementated in a single line of code.You can refer to the following solution:<jupyter_code>mon_sales = "121"
tues_sales = "105"
wed_sales = "110"
thurs_sales = "98"
fri_sales = "95"

# TODO: Print a string with this format: This week's total sales: xxx
# You will probably need to write some lines of code before the print statement.

# ================================================= #
#               Put your code here                  #
# ================================================= #
weekly_sales = int(mon_sales) + int(tues_sales) + int(wed_sales) + int(thurs_sales) + int(fri_sales)
weekly_sales = str(weekly_sales)  # convert the type back!!
print("This week's total sales: " + weekly_sales)<jupyter_output>This week's total sales: 529
{'fraction_non_alphanumeric': 0.14499349804941483, 'fraction_numerical': 0.017230169050715213, 'mean_word_length': 5.166332665330661, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '575499', 'license': 'Apache-2.0', 'n_tokens_mistral': 995, 'n_tokens_neox': 903, 'n_words': 406, 'path': 'projects/Questions.ipynb', 'repo_name': 'monaen/DHLO2021-2021Spring', 'size': '3076'}