Python List Use Cases & Real Time Scenarios | Solve the hardest problem using List Comprehension 🔥

Поделиться
HTML-код
  • Опубликовано: 30 ноя 2024

Комментарии • 71

  • @shrutisamal
    @shrutisamal 8 месяцев назад +8

    I have taken up many paid and unpaid python courses from a number of popular programs out there but never got this much clarity and understanding on list comprehension. Your method of teaching with so many real time scenarios is truly exceptional. The content is pure gold. Underrated channel. Thank you so much Sumit Sir! looking forward to the upcoming session

  • @vishal-ox3zd
    @vishal-ox3zd 7 месяцев назад

    Hi Sumit Sir , I just love the way you are teaching. I have seen many youtube videos on python but this python course is unique.the content of this course helps me a lot to understand many concepts of python. Please share some more concepts of python which will help data engineers like us.
    Really you are a great teacher 🙏
    Thanks a lot.

  • @vandanapatil8182
    @vandanapatil8182 8 месяцев назад +3

    Best teacher in india 😊🎉

  • @faizanmidda1337
    @faizanmidda1337 8 месяцев назад +1

    Sir. Also please teach OS module and how to handle excel files. I love the way you teach.

  • @venkateshkannan7398
    @venkateshkannan7398 8 месяцев назад +2

    Solution to Assignment3(my tiny contribution). Im using defaultdict(), a subclass of Dictionary. I find it handy when working with lists.
    from collections import defaultdict
    company_average = defaultdict(list)
    for sublist in company:
    company_average[sublist[2]].append(sublist[3])
    average_salaries = {department: sum(salaries) / len(salaries) for department, salaries in company_average.items()}
    print(average_salaries)

  • @Mahakal_Status_g6y
    @Mahakal_Status_g6y 11 дней назад +1

    how can i learn to implement logic like you sir BTW your videos are too good 😃

  • @arunsundar3739
    @arunsundar3739 8 месяцев назад

    it was fun to know & see the benefits of List comprehension & various other concepts of Python, had little hesitancy to learn one another programming language, now i can embrace Python after seeing it is easy to learn from this Python series & also more importantly apply it in Pyspark code :)

  • @sidhantdorge2445
    @sidhantdorge2445 8 месяцев назад +1

    Hey guys,
    Sharing my approach which I used to solve the Assignments that Sumit Sir mentioned in the session
    Assignment-1:
    status_list = ['CLOSED', 'PENDING_PAYMENT', 'COMPLETE', 'CLOSED', 'COMPLETE', 'COMPLETE', 'COMPLETE', 'PROCESSING', 'PENDING_PAYMENT', 'PENDING_PAYMENT']
    status_list_set = set(status_list)
    print(status_list_set)
    order_status_count = [(status,status_list.count(status)) for status in status_list_set]
    print(order_status_count)
    Assignment-2:
    order_list = [
    [1, 100, 'success'],
    [2, 200, 'pending'],
    [3, 150, 'success'],
    [4, 300, 'failed'],
    [5, 400, 'success'],
    [6, 250, 'pending'],
    [7, 350, 'failed'],
    [8, 450, 'success'],
    [9, 500, 'pending'],
    [10, 600, 'failed']
    ]
    order_list_status = [orders[2] for orders in order_list]
    order_list_status_set = set(order_list_status)
    status_count = [(status, order_list_status.count(status)) for status in order_list_status_set]
    for status in status_count:
    print(f"{status[0]} : {status[1]}")
    Assignment-3:
    employee_salary = [
    [101, 'John', 'IT', 60000],
    [102, 'Alice', 'HR', 50000],
    [103, 'Bob', 'Finance', 70000],
    [104, 'Emma', 'IT', 55000],
    [105, 'David', 'Finance', 75000],
    [106, 'Sophia', 'HR', 48000]
    ]
    finance_sal=[]
    it_sal = []
    hr_sal = []
    for item in employee_salary:
    if item[2] == "IT":
    it_sal.append(item[3])
    elif item[2] == "HR":
    hr_sal.append(item[3])
    else:
    finance_sal.append(item[3])
    finance_avg_sal = sum(finance_sal)/len(finance_sal)
    hr_avg_sal = sum(hr_sal)/len(hr_sal)
    it_avg_sal = sum(it_sal)/len(it_sal)
    print(f"Finance: Average Salary - {finance_avg_sal}")
    print(f"IT: Average Salary - {it_avg_sal}")
    print(f"HR: Average Salary - {hr_avg_sal}")
    Please feel free to add any suggestions you have or any doubts that you need to clarify, I am happy to help.

    • @DileepNelliakkattu
      @DileepNelliakkattu 6 месяцев назад

      One problem with this solution is that this code needs to change when the input has more departments, so this is not a generic solution

  • @venkateshkannan7398
    @venkateshkannan7398 8 месяцев назад +1

    Best video on lists and tuples!

  • @vandanapatil8182
    @vandanapatil8182 8 месяцев назад +2

    Sir we want same type of in depth lectures/playlist on
    Excel & power BI for Data Analyst
    with real industry relevant projects
    😊

  • @abhishekn786
    @abhishekn786 8 месяцев назад +1

    Top notch content sir, really loved it.
    please upload videos as fast as you can.
    Thanks

    • @sumitmittal07
      @sumitmittal07  8 месяцев назад

      glad that you enjoyed the session

  • @ArpitSrivastava1994
    @ArpitSrivastava1994 8 месяцев назад

    Very clear and super helpful examples taken

  • @gauravrai4398
    @gauravrai4398 5 месяцев назад

    🔥🔥🔥🔥🔥🔥🔥🔥 on fire content .... many thanks Sumit Sir .... i am a bit late but catching up on all the videos in this playlist

  • @swapnam1528
    @swapnam1528 6 месяцев назад

    Videos are really helpful. I have not seen such videos with real time examples. i am truly enjoying the sessions. Sir is it possible to create video for oops concepte.

  • @swapnam1528
    @swapnam1528 6 месяцев назад

    nested_lists=[[i,i**2,i**3] for i in range(1,4)]
    print(nested_lists)

  • @arpithaks3467
    @arpithaks3467 8 месяцев назад +3

    please share running notes

  • @mehulthakur5449
    @mehulthakur5449 2 месяца назад

    dep_avg_sal = []
    emp_department = [ emp[2] for emp in employees ]
    emp_set = set(emp_department)
    for emp_dep in emp_set:
    count = 0
    total_sum = 0
    for dep_sal in employees:
    if dep_sal[2] == emp_dep:
    total_sum += dep_sal[3]
    count += 1
    sal_avg = total_sum / count
    dep_avg_sal.append((emp_dep, sal_avg))
    print(dep_avg_sal)

  • @SoumyaBiswas37
    @SoumyaBiswas37 28 дней назад

    Sir, if I want to take a value during run time and want to add it within the nested list, Can it be possible with list comprehension??

  • @richaandparas4285
    @richaandparas4285 7 месяцев назад

    Assignment 3 solution using list comprehension -
    dept_lst = [emp[2] for emp in emp_lst]
    dept_set = set(dept_lst)
    avg_lst = [[dept, sum([emp[3] for emp in emp_lst if emp[2] == dept])/len([x[2] for x in emp_lst if x[2] == dept])] for dept in dept_set]

  • @azharaktherk2432
    @azharaktherk2432 8 месяцев назад

    For that 3rd assignment it will be very helpful if you can share the solution sir.

  • @vikaschavan6118
    @vikaschavan6118 8 месяцев назад

    Incredible, i enjoyed thoroughly. Just one question sir when we are doing word count, do you really feel we need to remove duplicate first? For example a paragraph may certain words which were repeated. If we remove duplicates then it will not give the result which we are looking for. Please share your thoughts on this

    • @vikaschavan6118
      @vikaschavan6118 8 месяцев назад

      input_list = ['CLOSED', 'PENDING_PAYMENT', 'COMPLETE', 'CLOSED', 'COMPLETE', 'COMPLETE', 'COMPLETE', 'PROCESSING', 'PENDING_PAYMENT', 'PENDING_PAYMENT']
      status_cnt = [(status,input_list.count(status)) for status in input_list]
      print(status_cnt) #[('CLOSED', 2), ('PENDING_PAYMENT', 3), ('COMPLETE', 4), ('CLOSED', 2), ('COMPLETE', 4), ('COMPLETE', 4), ('COMPLETE', 4), ('PROCESSING', 1), ('PENDING_PAYMENT', 3), ('PENDING_PAYMENT', 3)]
      unique_status_cnt = list(set(status_cnt))
      print(unique_status_cnt) #[('COMPLETE', 4), ('PENDING_PAYMENT', 3), ('CLOSED', 2), ('PROCESSING', 1)]
      O/P:
      [('COMPLETE', 4), ('PENDING_PAYMENT', 3), ('CLOSED', 2), ('PROCESSING', 1)]
      Removing duplicate first--> gives wrong output
      input_list = ['CLOSED', 'PENDING_PAYMENT', 'COMPLETE', 'CLOSED', 'COMPLETE', 'COMPLETE', 'COMPLETE', 'PROCESSING', 'PENDING_PAYMENT', 'PENDING_PAYMENT']
      input_list_unique =list(set(input_list)) #removed duplicates
      status_cnt = [(status,input_list_unique.count(status)) for status in input_list_unique]
      print(status_cnt) #[('COMPLETE', 1), ('CLOSED', 1), ('PENDING_PAYMENT', 1), ('PROCESSING', 1)]
      O/P:
      [('COMPLETE', 1), ('CLOSED', 1), ('PENDING_PAYMENT', 1), ('PROCESSING', 1)]

  • @prashantchourasiya1202
    @prashantchourasiya1202 7 месяцев назад

    Wonderful as expected...

  • @siddhantmishra6581
    @siddhantmishra6581 3 месяца назад

    Assignment 3:
    seta = set()
    for sublist in employee:
    seta.add(sublist[2])
    lista = list(seta)
    print(lista)
    IT =[]
    HR =[]
    Finance =[]
    for sublist in employee:
    if sublist[2] == lista[0]:
    IT.append(sublist[3])
    elif sublist[2] == lista[1]:
    HR.append(sublist[3])
    else:
    Finance.append(sublist[3])
    print("IT :%.2f"%(sum(IT)/len(IT)))
    print("HR :%.2f"%(sum(HR)/len(HR)))
    print("Finance :%.2f"%(sum(Finance)/len(Finance)))

  • @sekharG-o7m
    @sekharG-o7m 8 месяцев назад

    could you pls make a video on cicd pipeline, agile methodology

  • @ManishSharma-wy2py
    @ManishSharma-wy2py 8 месяцев назад

    It was great learning ❤

  • @ameerullah2260
    @ameerullah2260 7 месяцев назад

    Hello sir, where are you putting notes for viewers?
    @Sumit Mittal

  • @shivamgupta8106
    @shivamgupta8106 7 месяцев назад

    Hi Sumit Sir we are saying tuple is immutable but tuple inside list is mutable is that correct.
    for Ex i/p[(100,5),(200,10)] o/p[(100,5,105),(200,10,220)]

  • @DileepNelliakkattu
    @DileepNelliakkattu 6 месяцев назад

    Below is the solution for 3rd question, Please suggest your improvements as this looks very complex to me
    dept_list=[i[2] for i in data]
    dept_set=set(dept_list)
    dept_count=[(i,dept_list.count(i)) for i in dept_set]
    print(dept_count)
    dept_sum=[ (j[2],j[3]) for i in dept_set for j in data if j[2]==i]
    print(dept_sum)
    for i in dept_count:
    count = 0
    sum = 0
    for j in dept_sum:
    if i[0]==j[0]:
    count += 1
    sum+=j[1]
    if i[1]==count:
    avg=sum/count
    print(f'{i[0]}:Averege salary {avg}')

  • @sreenivasulareddy-s1w
    @sreenivasulareddy-s1w 8 месяцев назад +1

    Hi Sumit sir
    Are you going to cover data libraries like PANDAS and NUMPY as part of these sessions later ?

  • @ameerullah2260
    @ameerullah2260 7 месяцев назад

    Hello sir, where are you putting notes for viewers?

  • @dhanushkumar7849
    @dhanushkumar7849 8 месяцев назад

    Assignment 2 solution :
    d=defaultdict(int)
    for i in trans:
    status=i[2]
    d[status]+=1
    for a,b in d.items():
    print(a,b)
    Assignment 3 solution :
    department_salary_sum = defaultdict(int)
    department_employee_count = defaultdict(int)
    for _,_,dept,salary in list1:
    department_salary_sum[dept] += salary
    department_employee_count[dept] += 1
    avg={dept:department_salary_sum[dept]/department_employee_count[dept] for dept in department_salary_sum }
    for dept, avg_salary in avg.items():
    print(f"{dept}: {avg_salary:.2f}")

  • @shantanuchaudhary1176
    @shantanuchaudhary1176 8 месяцев назад

    Sir please help with assignment 3

  • @sidhantdorge2445
    @sidhantdorge2445 8 месяцев назад

    Hello Sumit Sir,
    Just finished watching all the 4 video in your Python playlist, which are super insightful, just wanted to thank you for starting this course (for free) which will be beneficial for every student/employee. I have just finished the assignments that you mentioned at the end of this session, it was quite fun to solve did find the average salary one a bit tough but did not look for solution on GPT and gave it a shot and I am glad that I was able to solve it.🙂

    • @sumitmittal07
      @sumitmittal07  8 месяцев назад

      I am really happy to hear this

    • @sidhantdorge2445
      @sidhantdorge2445 8 месяцев назад

      Thank you @@sumitmittal07 Sir. For the assignment solutions I just wanted some of your thoughts and the community so should I share it here?.

  • @sohamchintawar4015
    @sohamchintawar4015 6 месяцев назад

    Hi Can you please share reference theory material and python files? You mentioned in few videos that its available but I couldn't find it

  • @vishaldeshatwad8690
    @vishaldeshatwad8690 8 месяцев назад

    Sir How many videos in total does it take to complete the
    python playlist

  • @sakshijain3534
    @sakshijain3534 8 месяцев назад

    someone please share solution of assignment 3 using list comprehension

  • @pramilasekar1975
    @pramilasekar1975 7 месяцев назад

    Assignement 1:
    for word in line_set:
    result_set.append((word,lines.count(word)))
    print(result_set)
    for the above code im getting the below code,
    [('COMPLETE', 4)]
    [('COMPLETE', 4), ('PENDING_PAYMENT', 3)]
    [('COMPLETE', 4), ('PENDING_PAYMENT', 3), ('CLOSED', 2)]
    [('COMPLETE', 4), ('PENDING_PAYMENT', 3), ('CLOSED', 2), ('PROCESSING', 1)]
    Please let me know how to get the last row alone?

    • @madhusudank9684
      @madhusudank9684 7 месяцев назад

      print(result_set) is under for loop. Its an indenting issue. Below updated code will give you the desired result.
      for word in line_set:
      result_set.append((word,lines.count(word)))
      print(result_set)

  • @gunjansharma3103
    @gunjansharma3103 8 месяцев назад

    😃😃

  • @asktostranger8296
    @asktostranger8296 8 месяцев назад

    Anyone got notes ???

  • @jaykumargupta3647
    @jaykumargupta3647 8 месяцев назад

    Devin ko sab aata h

  • @asktostranger8296
    @asktostranger8296 7 месяцев назад

    Anyone got notes please share 🙏

  • @kaladharnaidusompalyam851
    @kaladharnaidusompalyam851 8 месяцев назад

    👏👏🫰

  • @sakshijain3534
    @sakshijain3534 8 месяцев назад

    dep_list=[(1,'JOHN','IT',2000),(2,'sam','IT',2000),(3,'RAM','HR',3000)]
    dep_list_new=
    [(line[2],line[3]) for line in dep_list] //[('IT', 2000), ('IT', 2000), ('HR', 3000)]
    dept_salaries = {} //empty_dict
    [dept_salaries.setdefault(dept, []).append(salary) for dept, salary in dep_list_new]//{'IT': [2000, 2000], 'HR': [3000]}
    average_salaries = {dept: sum(salaries) / len(salaries) for dept, salaries in dept_salaries.items()}
    print(average_salaries)