World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Download our e-book of Introduction To Python
4.5 (1,292 Ratings)
559 Learners
Sulochana Kamshetty
a year ago
lst = [10, 20, 30, 40, 50, 60, 70]
cube = [x**3 for x in lst]
print(cube)
[1000, 8000, 27000, 64000, 125000, 216000, 343000]
odds= []
for i in range(10):
if i % 3 == 0:
odds. append(i)
print(odds)
[0, 3, 6, 9]
lst = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
odd= [x for x in lst if x % 3 == 0]
print(odd)
[0, 3, 6, 9]
lst = [10, 20, 30, 40, 50]
print(list(map(lambda x: x**3, lst)))
[1000, 8000, 27000, 64000, 125000]
lst = [x for x in range(100) if x % 3 == 0 if x % 7 == 0]
print(lst)
[0, 21, 42, 63, 84]
lst=[2, 3, 6, 9, 12, 18, 21, 24, 30]
cube = [x**3 for x in lst if x % 6== 0]
print(cube)
[216, 1728, 5832, 13824, 27000]
# a list of odd numbers between 1 and 50
odds = [i for i in range(1, 50) if i % 2!=0]
print(odds)
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]