-
- why is not all memory free when
Python
exits?
- why is not all memory free when
-
- write the output of below code:
var1 = lambda q: q * 5
var2 = lambda q: q * 3
x = 2
x = var1(x)
x = var1(x)
x = var2(x)
print(x)
Ans: 150
-
- write the output of below code:
class A(object):
val = 1
class B(A):
pass
class C(A):
pass
print(A.val, B.val, c.val)
B.val = 20
print(A.val, B.val, c.val)
A.Val = 30
print(A.val, B.val, c.val)
Ans: 1 1 1 1 20 1 30 20 30
-
- Write a
Python
snippet to find unique element in a list.
- Write a
-
- write a
Python
programto reverse all words in a file and write reversed word into another file.
- write a
-
- What are
Exception
Handling ? How do you achieve in python?
- What are
-
- Brief explain the following:
- Inheritance
- init method
- String slice
- String Concation
- super
-
- Write a python program for below problem:
dict1 = {'fgx23': 23, 'dx22a': 2, 'dsw23': 10, 'as15': 17, 'fk112': 25}
dict2 = {'dx22a': 9, 'dsw23': 1, 'fgx23', 20, 'fk112': 12}
How to add the numbers(value) that have same code(key) in both dictionary? Example: dict1 has key 'dx22a' with value 2 and the dict2 has same 'dx22a' with value 9 the result should be in dict3 with key 'dx22a' with value 11. outputformat:
dict3 = {'fgx23': 43, 'dx2a': 11, 'dsw23': 11, ....etc}
-
- Write a python script that recursivly walks all sub directories and search all files with exentension *jpg, *.jpeg append them into the list Ans:
import os
sub = []
for dirs in os.walk('.'):
for j in (dirs[2]):
if j.lower().split('.')[1] in ('jpg','jpeg'):
sub.append(j)
print(sub)
-
- Explain enumarator , zip and generator funtion in python.
-
- Write a python list comprehension which generate a list of numbers which are odd and divisble by 3 for range n. Ans:
result = [i for i in range(n) if not i%2 == 0 and i%3 == 0] # n can be any positive integers