author | Anoop Jacob Thomas<anoop@fossee.in> |
Sat, 18 Dec 2010 12:54:49 +0530 | |
changeset 524 | b602b4dcc87d |
parent 522 | d33698326409 |
permissions | -rw-r--r-- |
522
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
1 |
Objective Questions |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
2 |
------------------- |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
3 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
4 |
.. A mininum of 8 questions here (along with answers) |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
5 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
6 |
1. How do you create an empty list? :: |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
7 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
8 |
empty=[] |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
9 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
10 |
2. What is the most important property of sequence data types like lists? |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
11 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
12 |
The elements are in order and can be accessed by index numbers. |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
13 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
14 |
3. Can you have a list inside a list ? |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
15 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
16 |
Yes,List can contain all the other data types, including list. |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
17 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
18 |
Example: |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
19 |
list_in_list=[2.3,[2,4,6],'string,'all datatypes can be there'] |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
20 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
21 |
4. What is the index number of the first element in a list? |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
22 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
23 |
0 |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
24 |
nonempty = ['spam', 'eggs', 100, 1.234] |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
25 |
nonempty[0] |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
26 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
27 |
5. How would you access the end of a list without finding its length? |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
28 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
29 |
Using negative indices. We can the list from the end using negative indices. |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
30 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
31 |
:: |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
32 |
nonempty = ['spam', 'eggs', 100, 1.234] |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
33 |
nonempty[-1] |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
34 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
35 |
6. What is the function to find the length of a list? |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
36 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
37 |
len |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
38 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
39 |
7. Delete the last element from list sq=[5,4,3,2,1,0] |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
40 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
41 |
del(sq[-1]) |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
42 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
43 |
8. How many will you have to use remove function to remove all 6's from the given list sq=[2,5,6,7,6,4,6]? |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
44 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
45 |
3 |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
46 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
47 |
Larger Questions |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
48 |
---------------- |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
49 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
50 |
.. A minimum of 2 questions here (along with answers) |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
51 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
52 |
1. Add all elemets of seq1=['e','f','g','h'] |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
53 |
to the sequence seq=['a','b','c','d'] |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
54 |
|
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
55 |
2. Delete all elements of seq1=[3,5,6] from sequence |
d33698326409
Renamed all LOs to match with their names in progress.org.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
56 |
seq=[1,2,3,4,5,6,7,8,9] |