at 0x000002419F463BA0>"
274 | ]
275 | },
276 | "execution_count": 9,
277 | "metadata": {},
278 | "output_type": "execute_result"
279 | }
280 | ],
281 | "source": [
282 | "ev_gen = (x for x in range(10) if x%2==0)\n",
283 | "ev_gen"
284 | ]
285 | },
286 | {
287 | "cell_type": "code",
288 | "execution_count": 10,
289 | "id": "64af1bb0",
290 | "metadata": {},
291 | "outputs": [
292 | {
293 | "data": {
294 | "text/plain": [
295 | "112"
296 | ]
297 | },
298 | "execution_count": 10,
299 | "metadata": {},
300 | "output_type": "execute_result"
301 | }
302 | ],
303 | "source": [
304 | "sys.getsizeof(ev_gen)"
305 | ]
306 | },
307 | {
308 | "cell_type": "code",
309 | "execution_count": 11,
310 | "id": "c3377cae",
311 | "metadata": {},
312 | "outputs": [
313 | {
314 | "name": "stdout",
315 | "output_type": "stream",
316 | "text": [
317 | "0\n",
318 | "2\n",
319 | "4\n",
320 | "6\n",
321 | "8\n"
322 | ]
323 | }
324 | ],
325 | "source": [
326 | "for num in ev_gen:\n",
327 | " print(num)"
328 | ]
329 | },
330 | {
331 | "cell_type": "code",
332 | "execution_count": 12,
333 | "id": "e2a31ef6",
334 | "metadata": {},
335 | "outputs": [
336 | {
337 | "name": "stdout",
338 | "output_type": "stream",
339 | "text": [
340 | "0\n",
341 | "1\n",
342 | "4\n",
343 | "9\n",
344 | "16\n",
345 | "25\n",
346 | "36\n",
347 | "49\n",
348 | "64\n",
349 | "81\n"
350 | ]
351 | }
352 | ],
353 | "source": [
354 | "squares_gen = (x**2 for x in range(10))\n",
355 | "\n",
356 | "for square in squares_gen:\n",
357 | " print(square)\n"
358 | ]
359 | },
360 | {
361 | "cell_type": "code",
362 | "execution_count": 13,
363 | "id": "8e196364",
364 | "metadata": {},
365 | "outputs": [
366 | {
367 | "data": {
368 | "text/plain": [
369 | "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]"
370 | ]
371 | },
372 | "execution_count": 13,
373 | "metadata": {},
374 | "output_type": "execute_result"
375 | }
376 | ],
377 | "source": [
378 | "[x**2 for x in range(10)]"
379 | ]
380 | },
381 | {
382 | "cell_type": "code",
383 | "execution_count": 14,
384 | "id": "fce18263",
385 | "metadata": {},
386 | "outputs": [
387 | {
388 | "name": "stdout",
389 | "output_type": "stream",
390 | "text": [
391 | "0\n",
392 | "2\n",
393 | "4\n",
394 | "6\n",
395 | "8\n"
396 | ]
397 | },
398 | {
399 | "data": {
400 | "text/plain": [
401 | "[None, None, None, None, None]"
402 | ]
403 | },
404 | "execution_count": 14,
405 | "metadata": {},
406 | "output_type": "execute_result"
407 | }
408 | ],
409 | "source": [
410 | "[print(x) for x in range(10) if x%2==0]"
411 | ]
412 | },
413 | {
414 | "cell_type": "code",
415 | "execution_count": 15,
416 | "id": "60adb567",
417 | "metadata": {},
418 | "outputs": [
419 | {
420 | "data": {
421 | "text/plain": [
422 | "112"
423 | ]
424 | },
425 | "execution_count": 15,
426 | "metadata": {},
427 | "output_type": "execute_result"
428 | }
429 | ],
430 | "source": [
431 | "sys.getsizeof(ev_gen)"
432 | ]
433 | },
434 | {
435 | "cell_type": "markdown",
436 | "id": "fbf6561a",
437 | "metadata": {},
438 | "source": [
439 | "# List Comprehensions vs Generators in Python\n",
440 | "\n",
441 | "Both list comprehensions and generators provide concise ways to create iterators in Python. However, they serve different purposes and have different characteristics.\n",
442 | "\n",
443 | "## List Comprehensions\n",
444 | "\n",
445 | "List comprehensions are a compact way to create lists. They are enclosed in square brackets `[]` and can include conditions and nested loops.\n",
446 | "\n",
447 | "### Syntax\n",
448 | "\n",
449 | "```python\n",
450 | "[expression for item in iterable if condition] #List Comprehension\n",
451 | "(expression for item in iterable if condition) #Generator\n"
452 | ]
453 | },
454 | {
455 | "cell_type": "markdown",
456 | "id": "25abfbb0",
457 | "metadata": {},
458 | "source": [
459 | "| Feature | List Comprehensions | Generators |\n",
460 | "|--------------------------|------------------------------------------|---------------------------------------------|\n",
461 | "| **Syntax** | `[expression for item in iterable]` | `(expression for item in iterable)` |\n",
462 | "| **Evaluation** | Immediate (all items at once) | Lazy (one item at a time) |\n",
463 | "| **Memory Usage** | Stores entire list in memory | Memory efficient (no storage of entire list)|\n",
464 | "| **Iteration** | Can be iterated multiple times | Can be iterated only once |\n",
465 | "| **Use Case** | Small to medium-sized lists | Large datasets or infinite sequences |\n",
466 | "| **Speed** | Faster for small datasets | Generally slower due to lazy evaluation |\n"
467 | ]
468 | },
469 | {
470 | "cell_type": "code",
471 | "execution_count": 16,
472 | "id": "014336f6",
473 | "metadata": {},
474 | "outputs": [
475 | {
476 | "data": {
477 | "text/plain": [
478 | "[0, 4, 16, 36, 64]"
479 | ]
480 | },
481 | "execution_count": 16,
482 | "metadata": {},
483 | "output_type": "execute_result"
484 | }
485 | ],
486 | "source": [
487 | "# List comprehension\n",
488 | "even_squares = [x**2 for x in range(10) if x % 2 == 0]\n",
489 | "even_squares"
490 | ]
491 | },
492 | {
493 | "cell_type": "code",
494 | "execution_count": 17,
495 | "id": "4aa47902",
496 | "metadata": {},
497 | "outputs": [
498 | {
499 | "name": "stdout",
500 | "output_type": "stream",
501 | "text": [
502 | "0\n",
503 | "4\n",
504 | "16\n",
505 | "36\n",
506 | "64\n"
507 | ]
508 | }
509 | ],
510 | "source": [
511 | "# Generator expression\n",
512 | "even_squares_gen = (x**2 for x in range(10) if x % 2 == 0)\n",
513 | "\n",
514 | "for square in even_squares_gen:\n",
515 | " print(square)"
516 | ]
517 | },
518 | {
519 | "cell_type": "code",
520 | "execution_count": 18,
521 | "id": "9e14a4d0",
522 | "metadata": {},
523 | "outputs": [
524 | {
525 | "name": "stdout",
526 | "output_type": "stream",
527 | "text": [
528 | "List comprehension = 120\n",
529 | "Generator = 112\n"
530 | ]
531 | }
532 | ],
533 | "source": [
534 | "print('List comprehension =',sys.getsizeof(even_squares))\n",
535 | "print('Generator =',sys.getsizeof(even_squares_gen))"
536 | ]
537 | },
538 | {
539 | "cell_type": "code",
540 | "execution_count": 19,
541 | "id": "5fe2a0a8",
542 | "metadata": {},
543 | "outputs": [
544 | {
545 | "data": {
546 | "text/plain": [
547 | "(0, 4, 16, 36, 64)"
548 | ]
549 | },
550 | "execution_count": 19,
551 | "metadata": {},
552 | "output_type": "execute_result"
553 | }
554 | ],
555 | "source": [
556 | "even_squares_tuple = tuple(x**2 for x in range(10) if x % 2 == 0)\n",
557 | "even_squares_tuple"
558 | ]
559 | },
560 | {
561 | "cell_type": "code",
562 | "execution_count": 20,
563 | "id": "b23c3749",
564 | "metadata": {},
565 | "outputs": [
566 | {
567 | "data": {
568 | "text/plain": [
569 | "[0, 4, 16, 36, 64]"
570 | ]
571 | },
572 | "execution_count": 20,
573 | "metadata": {},
574 | "output_type": "execute_result"
575 | }
576 | ],
577 | "source": [
578 | "even_squares_list = list(x**2 for x in range(10) if x % 2 == 0)\n",
579 | "even_squares_list"
580 | ]
581 | },
582 | {
583 | "cell_type": "code",
584 | "execution_count": null,
585 | "id": "a129805b",
586 | "metadata": {},
587 | "outputs": [],
588 | "source": []
589 | }
590 | ],
591 | "metadata": {
592 | "kernelspec": {
593 | "display_name": "Python 3 (ipykernel)",
594 | "language": "python",
595 | "name": "python3"
596 | },
597 | "language_info": {
598 | "codemirror_mode": {
599 | "name": "ipython",
600 | "version": 3
601 | },
602 | "file_extension": ".py",
603 | "mimetype": "text/x-python",
604 | "name": "python",
605 | "nbconvert_exporter": "python",
606 | "pygments_lexer": "ipython3",
607 | "version": "3.9.13"
608 | }
609 | },
610 | "nbformat": 4,
611 | "nbformat_minor": 5
612 | }
613 |
--------------------------------------------------------------------------------
/OOP in Python.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rashakil-ds/60-Days-of-Python-by-Study-Mart-AI-QUEST/206265c75faf11936079af3bbaf4c6e6330884a6/OOP in Python.pdf
--------------------------------------------------------------------------------
/Python Problems.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rashakil-ds/60-Days-of-Python-by-Study-Mart-AI-QUEST/206265c75faf11936079af3bbaf4c6e6330884a6/Python Problems.pdf
--------------------------------------------------------------------------------
/Python Roadmap.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rashakil-ds/60-Days-of-Python-by-Study-Mart-AI-QUEST/206265c75faf11936079af3bbaf4c6e6330884a6/Python Roadmap.pdf
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 60 Days of Python by Study Mart & aiQuest Intelligence
5 |
6 |
7 | 60 Days of Python by Study Mart & aiQuest Intelligence
8 | Welcome to the 60 Days of Python repository! This repository contains 60 video materials ranging from basic to advanced Python, curated by Study Mart and aiQuest Intelligence.
9 |
10 | Course Name
11 | 60 Days of Python
12 |
13 | Topics Covered
14 |
15 | - Basic Python Programming
16 | - Intermediate Python Concepts
17 | - Advanced Python Techniques
18 |
19 |
20 | YouTube Video Playlist
21 | Watch the complete video playlist on YouTube: 60 Days of Python Playlist
22 |
23 | Repository Link
24 | Check out the collection of video materials here.
25 |
26 | Additional Resources
27 | We also offer a variety of paid courses on data science on our website. Visit AIQuest for more details.
28 | For free resources, check out our YouTube channel: StudyMart.
29 | Join our Facebook group for more discussions and resources: StudyMart Facebook Group.
30 |
31 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/test:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------