equal
deleted
inserted
replaced
|
1 Objective Questions |
|
2 ------------------- |
|
3 |
|
4 .. A mininum of 8 questions here (along with answers) |
|
5 |
|
6 1. How do you create an empty list? :: |
|
7 |
|
8 empty=[] |
|
9 |
|
10 2. What is the most important property of sequence data types like lists? |
|
11 |
|
12 The elements are in order and can be accessed by index numbers. |
|
13 |
|
14 3. Can you have a list inside a list ? |
|
15 |
|
16 Yes,List can contain all the other data types, including list. |
|
17 |
|
18 Example: |
|
19 list_in_list=[2.3,[2,4,6],'string,'all datatypes can be there'] |
|
20 |
|
21 4. What is the index number of the first element in a list? |
|
22 |
|
23 0 |
|
24 nonempty = ['spam', 'eggs', 100, 1.234] |
|
25 nonempty[0] |
|
26 |
|
27 5. How would you access the end of a list without finding its length? |
|
28 |
|
29 Using negative indices. We can the list from the end using negative indices. |
|
30 |
|
31 :: |
|
32 nonempty = ['spam', 'eggs', 100, 1.234] |
|
33 nonempty[-1] |
|
34 |
|
35 6. What is the function to find the length of a list? |
|
36 |
|
37 len |
|
38 |
|
39 7. |
|
40 |
|
41 Larger Questions |
|
42 ---------------- |
|
43 |
|
44 .. A minimum of 2 questions here (along with answers) |
|
45 |
|
46 1. Question 1 |
|
47 2. Question 2 |