Sets Practice Description Let’s say you have two lists A and B. Identify the elements which are common in the two lists A and B and return them in a sorted manner. For example Sample Input : A = [5,1,3,4,4,5,6,7] B = [3,3,5,5, 1 ,7 ,2] Sample Output: [1,3,5] If you observe the sample output here you can see that Though value 5 is repeated twice in both lists, in the final output it is present only once. The values are returned in a sorted manner with values increasing. Execution Time Limit 10 seconds SOLUTION CODE #code import ast,sys input_str = sys.stdin.read() input_list = ast.literal_eval(input_str) list_1 = input_list[0] list_2 = input_list[1] A = set(list_1) B = set(list_2) answer = list(A.intersection(B)) print(answer) 2) Sets What gets printed with the following set of instructions? nums = set ([ 1 , 1 , 2 , 3 , 3 , 3 , 4 ]) print ( len (nums)) 7 4 ✓ Correct Feedback: Set() removes duplicates and returns the unique values. Hence, nums would be updated as...
Variables In [1]: name = "mike" print ( name ) mike In [3]: name = input ( "Enter your name : " ) print ( "Welcome" , name ) Enter your name : Jane Welcome Jane Data Types in Python Here in the below piece of code you can see that we have assigned each variable with a particular value and use the type method we can check the datatype of the variable Variables In [1]: name = "mike" print ( name ) mike In [3]: name = input ( "Enter your name : " ) print ( "Welcome" , name ) Enter your name : Jane Welcome Jane Data Types in Python Here in the below piece of code you can see that we have assigned each variable with a particular value and use the type method we can check the datatype of the variable In [15]: integer_num = 1 floating_num = 1.3 string = 'Mike' boolean = True print ( type ( integer_num )) print ( type ( floating_num )) print ( type ( string )) print ( type ( boolean )) <clas...