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

  Рет қаралды 16,235

Sumit Mittal

Sumit Mittal

Күн бұрын

Пікірлер: 73
@shrutisamal
@shrutisamal 10 ай бұрын
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
@sumitmittal07
@sumitmittal07 10 ай бұрын
Great to hear!
@vishal-ox3zd
@vishal-ox3zd 9 ай бұрын
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 10 ай бұрын
Sir we want same type of in depth lectures/playlist on Excel & power BI for Data Analyst with real industry relevant projects 😊
@arunsundar3739
@arunsundar3739 10 ай бұрын
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 :)
@vandanapatil8182
@vandanapatil8182 10 ай бұрын
Best teacher in india 😊🎉
@sumitmittal07
@sumitmittal07 10 ай бұрын
thank you for tour kind words
@sribalaji7131
@sribalaji7131 9 ай бұрын
for the world💌
@faizanmidda1337
@faizanmidda1337 10 ай бұрын
Sir. Also please teach OS module and how to handle excel files. I love the way you teach.
@gauravrai4398
@gauravrai4398 7 ай бұрын
🔥🔥🔥🔥🔥🔥🔥🔥 on fire content .... many thanks Sumit Sir .... i am a bit late but catching up on all the videos in this playlist
@venkateshkannan7398
@venkateshkannan7398 10 ай бұрын
Best video on lists and tuples!
@sumitmittal07
@sumitmittal07 10 ай бұрын
Yay! Thank you!
@abhishekn786
@abhishekn786 10 ай бұрын
Top notch content sir, really loved it. please upload videos as fast as you can. Thanks
@sumitmittal07
@sumitmittal07 10 ай бұрын
glad that you enjoyed the session
@swapnam1528
@swapnam1528 8 ай бұрын
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.
@Soham_Posts
@Soham_Posts 2 ай бұрын
how can i learn to implement logic like you sir BTW your videos are too good 😃
@venkateshkannan7398
@venkateshkannan7398 10 ай бұрын
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)
@sumitmittal07
@sumitmittal07 10 ай бұрын
that's great
@mehulthakur5449
@mehulthakur5449 4 ай бұрын
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)
@ArpitSrivastava1994
@ArpitSrivastava1994 10 ай бұрын
Very clear and super helpful examples taken
@sumitmittal07
@sumitmittal07 10 ай бұрын
Glad it was helpful!
@attaullahansari592
@attaullahansari592 27 күн бұрын
Thank you sir!
@sidhantdorge2445
@sidhantdorge2445 10 ай бұрын
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 8 ай бұрын
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
@SoumyaBiswas37
@SoumyaBiswas37 2 ай бұрын
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??
@prashantchourasiya1202
@prashantchourasiya1202 9 ай бұрын
Wonderful as expected...
@ManishSharma-wy2py
@ManishSharma-wy2py 10 ай бұрын
It was great learning ❤
@vikaschavan6118
@vikaschavan6118 10 ай бұрын
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 10 ай бұрын
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)]
@sidhantdorge2445
@sidhantdorge2445 10 ай бұрын
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 10 ай бұрын
I am really happy to hear this
@sidhantdorge2445
@sidhantdorge2445 10 ай бұрын
Thank you @@sumitmittal07 Sir. For the assignment solutions I just wanted some of your thoughts and the community so should I share it here?.
@shivamgupta8106
@shivamgupta8106 9 ай бұрын
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)]
@azharaktherk2432
@azharaktherk2432 10 ай бұрын
For that 3rd assignment it will be very helpful if you can share the solution sir.
@arpithaks3467
@arpithaks3467 10 ай бұрын
please share running notes
@swapnam1528
@swapnam1528 8 ай бұрын
nested_lists=[[i,i**2,i**3] for i in range(1,4)] print(nested_lists)
@sekharG-o7m
@sekharG-o7m 10 ай бұрын
could you pls make a video on cicd pipeline, agile methodology
@ameerullah2260
@ameerullah2260 9 ай бұрын
Hello sir, where are you putting notes for viewers? @Sumit Mittal
@ameerullah2260
@ameerullah2260 9 ай бұрын
Hello sir, where are you putting notes for viewers?
@richaandparas4285
@richaandparas4285 9 ай бұрын
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]
@DileepNelliakkattu
@DileepNelliakkattu 8 ай бұрын
This is working perfectly, Thank you
@sohamchintawar4015
@sohamchintawar4015 8 ай бұрын
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
@DileepNelliakkattu
@DileepNelliakkattu 8 ай бұрын
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 10 ай бұрын
Hi Sumit sir Are you going to cover data libraries like PANDAS and NUMPY as part of these sessions later ?
@sumitmittal07
@sumitmittal07 10 ай бұрын
yes I will cover
@sreenivasulareddy-s1w
@sreenivasulareddy-s1w 10 ай бұрын
Thank You Sir
@skjahangir3800
@skjahangir3800 10 ай бұрын
@@sumitmittal07 sir when will be the next video on Python
@dhanushkumar7849
@dhanushkumar7849 10 ай бұрын
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}")
@siddhantmishra6581
@siddhantmishra6581 5 ай бұрын
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)))
@shantanuchaudhary1176
@shantanuchaudhary1176 10 ай бұрын
Sir please help with assignment 3
@vishaldeshatwad8690
@vishaldeshatwad8690 10 ай бұрын
Sir How many videos in total does it take to complete the python playlist
@sumitmittal07
@sumitmittal07 10 ай бұрын
total 10 in this playlist
@sakshijain3534
@sakshijain3534 10 ай бұрын
someone please share solution of assignment 3 using list comprehension
@pramilasekar1975
@pramilasekar1975 9 ай бұрын
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 9 ай бұрын
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)
@asktostranger8296
@asktostranger8296 10 ай бұрын
Anyone got notes ???
@gunjansharma3103
@gunjansharma3103 10 ай бұрын
😃😃
@asktostranger8296
@asktostranger8296 10 ай бұрын
Anyone got notes please share 🙏
@jaykumargupta3647
@jaykumargupta3647 10 ай бұрын
Devin ko sab aata h
@kaladharnaidusompalyam851
@kaladharnaidusompalyam851 10 ай бұрын
👏👏🫰
@sakshijain3534
@sakshijain3534 10 ай бұрын
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)
Master Dictionary Data Structure in Python with Real time Use cases
52:06
요즘유행 찍는법
0:34
오마이비키 OMV
Рет қаралды 12 МЛН
Война Семей - ВСЕ СЕРИИ, 1 сезон (серии 1-20)
7:40:31
Семейные Сериалы
Рет қаралды 1,6 МЛН
Who is More Stupid? #tiktok #sigmagirl #funny
0:27
CRAZY GREAPA
Рет қаралды 10 МЛН
진짜✅ 아님 가짜❌???
0:21
승비니 Seungbini
Рет қаралды 10 МЛН
List Comprehension in Python
10:23
Neso Academy
Рет қаралды 35 М.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 478 М.
10 Python Comprehensions You SHOULD Be Using
21:35
Tech With Tim
Рет қаралды 168 М.
4 Recently asked Pyspark Coding Questions | Apache Spark Interview
28:39
Python Lists vs Tuples: Their Differences Explained in 5 Minutes
5:13
Coding with Estefania
Рет қаралды 18 М.
Python Language Fundamentals & String Operations | Session 2
1:22:48
Sumit Mittal
Рет қаралды 25 М.
Python List Comprehensions Made Easy!!
11:50
Travis Media
Рет қаралды 19 М.
요즘유행 찍는법
0:34
오마이비키 OMV
Рет қаралды 12 МЛН