Python Interview Questions Set - 13 Released
Uncategorized
Intermediate Level
Display numbers divisible by 5 from a list
lst_ = list(np.random.randint(10,99,100))
def isDivByFive(num):
return (num%5==0)
for n in lst_:
if isDivByFive(n):
print(n, end=",")
Create the dictionary with number and its square which is leas then or equal to given number.
ur_input = int(input("Enter Some Number: "))
res = {i: i**2 for i in range(1, ur_input+1)}
res
Remove the duplicate object from the list
l1 = [10,"22", 22, 'foo', 'bar', True, True, False, False, '22', 22, 10, 10]
res = list(set(l1))
res
Create the pandas dataframe using dictionary
dict_ = {"ID":[i for i in range(100)], "Qty":np.random.randint(10,99,100), "PUP":np.random.randint(99,999,100)}
df = pd.DataFrame(dict_)
df.head()
Write the python program to convert the decimal to binary
ur_input = int(input("Enter Some Number: "))
def convertToBinary(num):
return bin(num)[2:]
res = convertToBinary(ur_input)
res
Recent Comments
Archives
Categories
Categories
- Inspiration (1)
- Style (1)
- Technical Blog (18)
- Tips & tricks (2)
- Uncategorized (21)