22 solutions available
Question 7What are the two ways to add something to a list ? How are they different ?
Question 8What are the two ways to remove something from a list? How are they different ?
Question 19How is del D and del D[<key>] different from one another if D is a dictionary ?
Question 20Create a dictionary named D with three entries, for keys 'a', 'b' and 'c'. What happens if you try to index a nonexistent key (D['d']) ?...
Question 21What is sorting ? Name some popular sorting techniques.
Question 22Discuss Bubble sort and Insertion sort techniques.
Question 1(a)What will be the output produced by following code fragments ?y = str(123) x = "hello" \* 3 print(x, y) x = "hello" + "world" y...
Question 1(c)What will be the output produced by following code fragments ?x = "hello world" print(x[:2], x[:-2], x[-2:]) print(x[6], x[2:4])...
Question 2Write a short Python code segment that adds up the lengths of all the words in a list and then prints the average (mean) length.
Question 3Predict the output of the following code snippet ?a = [1, 2, 3, 4, 5] print(a[3:0:-1])
Question 4(a)Predict the output of the following code snippet?arr = [1, 2, 3, 4, 5, 6] for i in range(1, 6): arr[i - 1] = arr[i] for i in...
Question 6Assuming words is a valid list of words, the program below tries to print the list in reverse. Does it have an error ? If so, why ? (Hint....
Question 7What would be the output of following code if ntpl = ("Hello", "Nita", "How's", "life ?") ?(a, b, c, d) = ntpl print("a is:", a) print("b...
Question 8What will be the output of the following code ?tuple_a = 'a', 'b' tuple_b = ('a', 'b') print (tuple_a == tuple_b)
Question 9What will be the output of the following code snippet ?rec = {"Name" : "Python", "Age" : "20", "Addr" : "NJ", "Country" : "USA"} id1 =...
Question 10Write the output of the code given below :my_dict = {"name" : "Aman", "age" : 26} my_dict['age'] = 27 my_dict['address'] = "Delhi"...
Question 11Write a method in python to display the elements of list thrice if it is a number and display the element terminated with '#' if it is not...
Question 2Write a program that should prompt the user to type some sentence(s) followed by "enter". It should then print the original sentence(s) and...
Question 9Create a dictionary whose keys are month names and whose values are the number of days in the corresponding months.(a) Ask the user to...
Question 10Write a function called addDict(dict1, dict2) which computes the union of two dictionaries. It should return a new dictionary, with all...
Question 11Write a program to sort a dictionary's keys using Bubble sort and produce the sorted keys as a list.Solutionmy_dict = eval(input("Enter...
Question 12Write a program to sort a dictionary's values using Bubble sort and produce the sorted values as a list.Solutionmy_dict =...