author | Puneeth Chaganti <punchagan@fossee.in> |
Wed, 10 Nov 2010 10:24:03 +0530 | |
changeset 435 | 975677bf1b8a |
parent 335 | d5248a15274c |
child 465 | 78d20cd87c7e |
permissions | -rw-r--r-- |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
1 |
Objective Questions |
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
2 |
------------------- |
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
3 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
4 |
1. Which of the following variables contains the locations to search for |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
5 |
python modules |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
6 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
7 |
a. sys.pythonpath |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
8 |
#. sys.path |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
9 |
#. os.pythonpath |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
10 |
#. os.path |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
11 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
12 |
Answer: sys.path |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
13 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
14 |
2. What is the type of ``sys.path`` |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
15 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
16 |
a. list of strings |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
17 |
#. list of int |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
18 |
#. string |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
19 |
#. tuple of strings |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
20 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
21 |
Answer: list of strings |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
22 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
23 |
3. The script ``utils.py`` is in one of locations of PYTHONPATH and contains |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
24 |
the following code: |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
25 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
26 |
def show(x): |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
27 |
print x |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
28 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
29 |
show("Hello World") |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
30 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
31 |
if __name__ == "__main__": |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
32 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
33 |
show("Hello Test") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
34 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
35 |
How do you import the file. |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
36 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
37 |
a. import utils |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
38 |
#. import utils.py |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
39 |
#. import /home/user/utils |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
40 |
#. import /home/user/utils.py |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
41 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
42 |
Answer: import utils |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
43 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
44 |
4. The script ``utils.py`` is in one of locations of PYTHONPATH and contains |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
45 |
the following code: |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
46 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
47 |
def show(x): |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
48 |
print x |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
49 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
50 |
show("Hello World") |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
51 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
52 |
if __name__ == "__main__": |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
53 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
54 |
show("Hello Test") |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
55 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
56 |
How do you use the ``show`` function after doing ``import utils`` |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
57 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
58 |
a. utils.show("hey") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
59 |
#. show("hey") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
60 |
#. utils.py.show("hey") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
61 |
#. utils.py.show.py("hey") |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
62 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
63 |
Answer: utils.show("hey") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
64 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
65 |
5. The script ``utils.py`` is in one of locations of PYTHONPATH and contains |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
66 |
the following code: |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
67 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
68 |
def show(x): |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
69 |
print x |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
70 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
71 |
show("Hello World") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
72 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
73 |
if __name__ == "__main__": |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
74 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
75 |
show("Hello Test") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
76 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
77 |
How do you use the ``show`` function after doing ``from utils import show`` |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
78 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
79 |
a. utils.show("hey") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
80 |
#. show("hey") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
81 |
#. utils.py.show("hey") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
82 |
#. utils.py.show.py("hey") |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
83 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
84 |
Answer: show("hey") |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
85 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
86 |
5. The script ``utils.py`` is in one of locations of PYTHONPATH and contains |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
87 |
the following code: |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
88 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
89 |
def show(x): |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
90 |
print x |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
91 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
92 |
show("Hello World") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
93 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
94 |
if __name__ == "__main__": |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
95 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
96 |
show("Hello Test") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
97 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
98 |
What is printed when you do ``import utils`` |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
99 |
|
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
100 |
Answer:: |
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
101 |
Hello World |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
102 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
103 |
6. The script ``utils.py`` is in one of locations of PYTHONPATH and contains |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
104 |
the following code: |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
105 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
106 |
def show(x): |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
107 |
print x |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
108 |
|
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
109 |
show("Hello World") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
110 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
111 |
if __name__ == "__main__": |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
112 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
113 |
show("Hello Test") |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
114 |
|
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
115 |
What is printed when the script is executed. |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
116 |
|
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
117 |
Answer:: |
335
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
118 |
Hello World |
d5248a15274c
Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents:
296
diff
changeset
|
119 |
Hello Test |
296
641a6ee868c0
made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
120 |