|
1 Objective Questions |
|
2 ------------------- |
|
3 |
|
4 .. A mininum of 8 questions here (along with answers) |
|
5 |
|
6 1. How large can an integer in Python be? |
|
7 |
|
8 Any Size. |
|
9 |
|
10 |
|
11 2. How do you define a complex number in Python? |
|
12 |
|
13 Using the following notation. |
|
14 |
|
15 [Real part] + [Imaginary part] j |
|
16 example :: |
|
17 |
|
18 c= 3.2 + 4.6j |
|
19 |
|
20 |
|
21 |
|
22 3. Look at the following piece of code :: |
|
23 |
|
24 In []: f or t |
|
25 Out[]:True |
|
26 |
|
27 What can you comment about the data type of f and t ? |
|
28 |
|
29 4. One major diffence between tuples and lists? |
|
30 |
|
31 Tuples are immutable while lists are not. |
|
32 |
|
33 |
|
34 5. Look at the following sequence :: |
|
35 |
|
36 In []:t=true |
|
37 NameError: name 'true' is not defined |
|
38 |
|
39 What might be the reason for error here? |
|
40 |
|
41 In this scenario , it seems the programmer wanted to create a variable t with the boolean value True with a capital T. Since no variable by the name true(small t) is known to the interpreter it gives a NameError. |
|
42 |
|
43 |
|
44 6. Put the following string in a variable quotation. |
|
45 "God doesn't play dice" -Albert Einstein |
|
46 |
|
47 quotation='''"God doesn't play dice" -Albert Einstein''' |
|
48 |
|
49 7. Given a tuple :: |
|
50 |
|
51 tup=(7,4,2,1,3,6,5,8) |
|
52 tup[-2] |
|
53 |
|
54 5 |
|
55 |
|
56 8. What is the syntax for checking containership in Python?:: |
|
57 |
|
58 element in sequence |
|
59 'l' in "Hello" |
|
60 True |
|
61 |
|
62 9. Split this string on whitespaces? :: |
|
63 |
|
64 string="Split this string on whitespaces?" |
|
65 |
|
66 string.split() |
|
67 |
|
68 10. What is the answer of 5/2 and 5.0/2 . If yes , why. |
|
69 |
|
70 Yes, There is a difference. |
|
71 Because one is integer division and other is float division. |
|
72 |
|
73 Larger Questions |
|
74 ---------------- |
|
75 |
|
76 .. A minimum of 2 questions here (along with answers) |
|
77 |
|
78 1. Given two lists for example, |
|
79 list1=[1,2,3,4] and list2=[1,2,3,4,5,6,7] write a program to remove one list from the other. |
|
80 |
|
81 |
|
82 #. Write a program to check if a string is palindrome? |
|
83 |