Questions

2 Marks Each

🎯

Test yourself on this topic

11 questions · timed · auto-graded

Question 12 Marks
Write definition of a Method COUNTNOW(PLACES) to find and display those place names, in which there are more than 5 characters.

For example:If the list PLACES contains [''DELHI'', ''LONDON'', ''PARIS'', ''NEW YORK'', ''DUBAI'']The following should get displayedLONDONNEW YORK

View full question & answer
Question 22 Marks
Write definition of a method ZeroEnding(SCORES) to add all those values in the list of SCORES, which are ending with zero (0) and display the sum.

For example,If the SCORES contain [200,456,300,100,234,678]The sum should be displayed as 600.

View full question & answer
Question 32 Marks
Write the definition of a function Reverse(X) in Python, to display the elements in reverse order such that each displayed element is the twice of the original element (element * 2) of the List X in the following manner:

Example:

If List X contains 7 integers is as follows:

X[0] X[1] X[2] X[3] X[4] X[5] X[6]
4 8 7 5 6 2 10

After executing the function, the array content should be displayed as follows:

View full question & answer
Question 42 Marks
For a given list of values in descending order, write a method in python to search for a value with the help of Binary Search method. The method should return position of the value and should return –1 if the value not present in the list.
View full question & answer
Question 62 Marks
Write a program to create the list and do the following operations using the predefined functions.

• To print sum of all element of the list• To find maximum element of the list• To find minimum element of the list• To find the length of the list• To sort the list in ascending order• To sort the list in descending order

View full question & answer
Question 72 Marks
With the help of the program, explain the different ways to accept the elements of the list and display all the elements.


Answer

In this case, while entering the list, we have to enter the
list in square bracket.
Input:
Enter the list[1,2,3,4]
Data Structure 97
Output:
[1, 2, 3, 4]
<class ‘list’>
Case 2:


In this case, we can enter the list elements segregated
with space. i.e
Input:
Enter the list : 1 2 3 4 5
Output:
[1, 2, 3, 4, 5]
<class ‘list’>
Case 3:


In this case, we can enter the list of items one by one
and add the element to the list using the append method.
i.e.
Input:
Enter a number: 1
Enter more data(y/n)? y
Enter a number: 4
Enter more data(y/n)? n
Output:
[1, 4]
<class ‘list’>

View full question & answer
Question 82 Marks
Consider the following randomly ordered numbers stored in a list
786, 234, 526, 132, 345, 467,
Show the content of list after the First, Second and Third pass of the bubble sort method used for arranging in ascending order?
Note: Show the status of all the elements after each pass very clearly underlining the changes.
Answer
Pass I → 234, 526, 132, 345, 467, 786
Pass II → 234, 132 , 345 , 467 , 526 , 786
Pass III → 132 , 234 , 345 , 467, 526, 786
View full question & answer
Question 92 Marks
Consider the following unsorted list :

[22, 54, 12, 90, 55, 78]Write the passes of selection sort for sorting the list in ascending order till the 3rd iteration.

Answer
Pass 1: [12, 54, 22, 90, 55, 78]
Pass 2 : [12, 22, 54, 90, 55, 78]
Pass 3 : [12, 22, 54, 90, 55, 78]
View full question & answer
Question 102 Marks
Consider the following unsorted list

79 19 43 52 3 95

Write the passes of bubble sort for sorting the list in ascending order till the 3rd iteration.

View full question & answer
Question 112 Marks
Define Sorting and name a few sorting techniques.
Answer
Sorting means to arrange the elements of a list either in ascending or descending order

Different types of sorting methods are Bubble sort, Selection Sort, Insertion Sort, Quick Sort, Bucket Sort.

View full question & answer
2 Marks Each - Computer Science STD 12 Commerce Questions - Vidyadip