<jupyter_start><jupyter_text>Introduction to Python    Data Types (Solutions)  1 - What are the Python most common built-in data types?     Give examples creating variables for each of them.<jupyter_code>an_integer = 2
a_float = 2.5
a_string = 'learning python is fun'
list1 = [1, 2, 5, 'lists are capable of storing multiple types']
boolean = an_integer > a_float<jupyter_output><empty_output><jupyter_text>2 - Exemplify at least 5 ways to convert data types, using the variables that were created in the previous question:<jupyter_code>float(an_integer)
int(a_float)
list(a_string)
str(an_integer)
str(a_float)<jupyter_output><empty_output><jupyter_text>3- Exemplify the use of individual or combined built-in data types to create the following data structures:  + A medical record  + A 3x3 pixel matrix in RGB format  + A set of geographical coordinates representing the Mayor's Office in 3 different cities<jupyter_code>medical_record = {"Name":"<NAME>", "Height": 183, "Weight": 73, "BirthDate": "08-01-2021"}
image1 = [[[242,255,255],[111,111,23],[254,254,254]],
         [[242,255,255],[111,111,23],[254,254,254]],
         [[242,255,255],[111,111,23],[254,254,254]]]
image1
image2 = {"red": [[242,255,255],[111,111,23],[254,254,254]],
         "green": [[242,255,255],[111,111,23],[254,254,254]],
         "blue": [[242,255,255],[111,111,23],[254,254,254]]}
image2
coordinates = [(-33.382523,-70.584099),(40.739582,-73.988358),(48.866081,2.316417)]<jupyter_output><empty_output><jupyter_text>4- Give some examples on how to access the data in the data structures created in the previous question:<jupyter_code>medical_record["Name"]
image1[0]
image2["red"]
coordinates[0]
coordinates[0][0]<jupyter_output><empty_output><jupyter_text>5- Explain with examples the differences between:  + Mutable and immutable types  + Container types  + Sequential types<jupyter_code>#lists are mutable

list1.append('last_object')
list1
# strings are immutable

a_string.capitalize() 
a_string
# Container types: tuple, list, set, dict<jupyter_output><empty_output><jupyter_text>+ A sequence is the generic term for an ordered set. The most important sequential types: **string, tuple, lists**+ Dictionaries are ordered since Python v. 3.7, but we cannnot access the elements sequentiallly.+ Containers are any object that holds an arbitrary number of other objects (def. from Stackoverflow) For example **sets** and **dicts** are container types, but are not sequential types<jupyter_code>new_set = set([70, 52, 65, 120, 3, 1])
new_set
new_set[0]  #error
new_dict = {'two':2,'four':4}
new_dict[0]  #error<jupyter_output><empty_output><jupyter_text>6 - Exemplify primitive/method calls on variables associated with data types that:+ Do not modify the variable and do not return values when the method is called  + Modify the variable but do not return values when the method is called  + Do not modify the variable but return values to the method call  + Modify the variable and return values to the method call<jupyter_code># Do not modify the variable and do not return values when the method is called

a = "a string"

value_returned = print(a)

print(value_returned)
# Modify the variable but do not return values when the method is called 

list1 = []

value_returned = list1.append('variable')

print(list1)
print(value_returned)
# Do not modify the variable but return values to the method call 
# a method in an immutable object

value_returned = a_string.upper()

print(a_string)
print(value_returned)
# Modify the variable and return values to the method call  

list1 = ["first", "second", "third"]

print(list1)

value_returned = list1.pop()

print(list1)
print(value_returned)<jupyter_output>['first', 'second', 'third']
['first', 'second']
third<jupyter_text>7- Exemplify the use of methods for:+ Test whether a string can be converted to an integer  + Test if a set is a subset of another set    + Concatenate two lists  + Count the occurrences of an element in a list<jupyter_code># a)
string_test = '15'
print(string_test.isdigit())
type(int(string_test))
# b)

subset_test = set([1,2,3])
set_test = set(range(10))
subset_test.issubset(set_test)
# c) 

list_1 = [2,3, 'random_string']
list_2 = [6.8, [24,25,26]]
print(list_1)

# in-place
list_1.extend(list_2)
print(list_1)

# creating another list

list_3 = list_1 + list_2
# d)

list_4 = ['VALE3', 'B3SA3', 'PETR4', 'BBAS3', 'VVAR3', 'VALE3', 'B3SA3', 'PETR4', 'BBAS3', 'VVAR3', 'VALE3', 'B3SA3', 'PETR4', 'BBAS3', 
          'VVAR3', 'VALE3', 'B3SA3', 'PETR4', 'BBAS3', 'VVAR3', 'VALE3', 'B3SA3', 'PETR4', 'BBAS3', 'VVAR3', 'VALE3', 'B3SA3', 'PETR4',
          'BBAS3', 'VALE3', 'B3SA3', 'PETR4', 'BBAS3', 'VALE3', 'B3SA3', 'PETR4', 'VALE3', 'B3SA3', 'VALE3']

list_4.count('VALE3')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13262099308610936, 'fraction_numerical': 0.07270060758432852, 'mean_word_length': 5.742937853107344, 'pattern_counts': {'":': 7, '<': 33, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '165954', 'license': 'Apache-2.0', 'n_tokens_mistral': 1857, 'n_tokens_neox': 1664, 'n_words': 507, 'path': 'Exercises/Exercise_1_Data_Types_Solutions.ipynb', 'repo_name': 'eftropiosk94/Python_Course', 'size': '4776'}