Tutorial 20- Become a Pro with Python List Comprehensions With 1 Line Of Code |Krish Naik Hindi

preview_player
Показать описание
List Comprehension is a concise way of creating lists in Python. It is a compact way of generating a new list from an existing list, sequence or any other iterable object. It uses a single line of code to create a list, making it faster and more efficient than writing a for loop.

--------------------------------------------------------------------------------------------------------
Best Affordable Data Science Course From Pwskills(6-7 Months)

Impact Batch:- Data-Science-Masters (Full Stack Data Science)
-----------------------------------------------------------------------------------------------------
Now I will be uplaoding videos of Data Science In Hindi.
#KrishNaikhindi #datascience
Connect with me here:
Рекомендации по теме
Комментарии
Автор

number = 30
prime_list = [x for x in range(2, number + 1) if all(x % y != 0 for y in range(2, x // 2 + 1))]
print(prime_list)

solution to last question, very informative session

fitcommonman
Автор

thank you for making the python series in hindi sir
its very helpful for me !

UMEHarshKumar
Автор

Very nice sir...please upload more videos in hindi ...

indrakumari
Автор

by tinkering a little, I got following code
I don't understand why is if not used along with i%x ==0.
This doesn't work with if and i%x !=0

number = 10
result = [2]
prime_num = [result.append(i) for i in range(3, number+1) if not [x for x in result if i%x == 0]]

print(result)

rutvikjoshi
Автор

AI artificial intelligence ka tutorial banao please

aarizmansuri
Автор

# check prime
number = 36
is_prime = number > 1 and all(number % i != 0 for i in range(2, int(number ** 0.5) + 1) if number % i == 0)
print(is_prime)

# prime list between 1-50
Prime_list = [number for number in range(0, 51) if number > 1 and all(number % i != 0 for i in range(2, int(number ** 0.5) + 1) if number % i == 0)]
print(Prime_list)

parvpaigwar