In the DNA example, to simplify the code, I would create a dictionary: pair = {"A":"T", "C":"G", "G":"C", "T":"A"} Then, instead of the nested if statements, do dna = {key:[val, pair[val]] for (key, val) in enumerate(strand1)}
I feel like dictionary comprehensions lose a little bit of its readability compared to a conventional loop once you start applying multiple conditions. Especially with group else statements rather than the traditional elif which (as you mentioned) doesn't exists within the comprehension. But really nice to know about the feature as it never occurred to me that this existed.
I absolutely agree! I find that Comprehensions are much more comprehendible with lists hahahaha when it comes to dictionaries - the syntax becomes un-Pythonic very fast 😅 With that said, I use it way more often than traditional loops. I think I trained my brain to actually find it intuitive 🙃 hahahaha
@@PythonSimplified even if it looks less redable, i so much enjoy using a comprehenssion of everything, agree with you [x:=str(i)+str(i)[-1] for i in range(0,20,10)][1]+'%' 🙂
Excellent work! The clarity and didactics with which you have explained each concept are impressive. You have managed to break down complex topics into simple and accessible explanations, which is essential for deep understanding. Your ability to maintain simplicity without losing the essence of the concepts is truly admirable. Keep it up! Congratulations..
@@PythonSimplified I concur. Using pop culture references not only makes things less tedious, but it really helps with comprehension. That's why this is my favorite coding channel. So many tutorials are just a monotonous voice on a bad mic with a screen recording of their IDE. Also just wanted to say you're a really good teacher.
Great video, it is too clear. A little variation of your code for the exercise #3: users = ["mariyasha888", "KnotABot", "SpongiBOBO", "IAMBATMAN"] keys = { "id": lambda id: id, "username": lambda username: users[username], "password": lambda passw: "".join(random.choices(string.printable, k=8)) } data = [{key:(val(i)) for (key,val) in keys.items()} for i in range(len(users))] Maybe it's not the best way to do it, but it's just for practice 🙃. I'm learning python 😅. and your videos are very useful!!!
First time it was overwhelming for me, but second time it was fun and I could understand it 100%. I need to implement this in real project before I forget it, Thanks a lot.
Will do! I'm waiting to finish my current Algorithms and DS 2 module in university before I can properly cover the topic 😉 (My final exam is in September, so not much longer to wait 😊)
This was a really good tutorial showing more uses for comprehensions. Thanks! Also, the addition of the slides showing the important notes was a really good add. That was very welcome. Thanks again!
My intuition tells me that range approach is faster, because zip approach must contain the procedure to compare between names and profs. Im a newbie for Python programming. Thank you for your videos, that help me a lot to learn Python.
Thank you so much for your comment Takeshi! 😃 I'm planning a live stream in which we will compare the two approaches! my intuition also tells me range() - however, with Python 3, the zip() approach is also very efficient so I'm expecting a very close battle 😉
lists/dicts comprehension are constantly on that line where they are either great and easy to make and read or just long and ugly and make it harder to read so sometimes they are great, but sometimes it´s just better to do normal for loops
I became mad after watching this video. But you are a great tutor. I became a fan of you. Love you and your English. Thank you so much🧐😵💫🤒. I request you to please start a complete python tutorial for beginners.
Thanks a lot ! ❤❤. I was learned something from you. You are also better than my python profesor . U r taught something to me recent days . U r way speech and teaching is amazing itz easy to understand (but some topics are tough ) although u r videos are great 🥰
Will you please explain in separate video about how to read multiple elements from user at time using split function . 2. How to sort a dictionary without converting to tulle
If it's just a simple code, go and use list/dict comprehension, but when you logic become more complex, you better write it the old way, it's lot easier to read. Just like lambda for simple function and not for complex function.
Thank you so much for your comment David! We will compare zip() and range() in an upcoming live stream, we'll see exactly which of them beats the other 😉
Lovely as always Mariya. I would like to point out that using the random module isn't safe for generating passwords. People might use it to generate passwords for their various accounts online. You could mention the secrets module which is advised and secure. Anyway keep up the good work. Love you ❤️
Thank you so much for the awesome tip, TechieGuy! 😃 Secrets is indeed much more randomized than Random! the only issue is - I couldn't find a secrets.choices() method but rather secrets.choice() which returns a single value instead of k of them. From my perspective, the last exercise seemed convoluted enough to avoid the additional list comprehension of: password = "".join([secrets.choice(string.printable) for i in range(8)]) That's why I went for Random instead... however - if this was a dedicated video for random passwords I'd definitely use Secrets instead 😉
1:07 why not use the dict constructor here instead of the loop? dict_names_professions = dict(zip(list_names, list_professions)) any differences , benefits from using the loop?
I'd expect the "zip" method to be the faster one because it was purpose-made for such cases and probably has some built-in optimizations, no? Also the list comprehension where we add "man" works without putting (key, val) in brackets.
hello i m from indian yours warm well come i saw yours python video are very great i want learn python i think always may be one day i will learn python but money fees problem but my dream that learn python bcoz i saw python code is so lovely and easy for write and understand yes sue we can do with python code many great thing so my simple and hamble request from you can you teach to me python step by step from beginning thanq
I think it would probably be faster to use the zip method. Two primary reasons, one being that with the range approach you have to check the list on each iteration, and two being since the zip function was probably programmed to do this efficiently it has a different method of accessing the objects. Just my guess!
very good very clever, very helpful.....but i rarely use these comprehensions and it would be faster for me to do it the long way than sit down to memorise the rules...then forget them.
That was my original plan, Dimitri! 😃but then I thought to myself - what's the problem with spaces? I couldn't find a single reason why they would be any different from the rest of the characters 🤷♀️ Some sites do prevent you from using spaces within passwords - but I don't think it's based on merit. Do you find that space-less passwords are more secure?
Because string.printable contains whitespace \t, , , at first i used to cut it at the end when i imported it, but for me better aproach was change the original string module and create printable_ww same but without white space, i would like to contribute to open source to change that for python 3.12 if comunity accepts it
Hi Sem 😃 MySQL is definitely on my to-do list! will cover it in my Linux machine in future tutorials. In the meanwhile, you can checkout my SQLite tutorials: ⭐ SQLite Backend for Beginners: ruclips.net/video/Ohj-CqALrwk/видео.html (please note - the above tutorial is missing connection.commit()) ⭐Web Scraping Databases with Mechanical Soup and Sqlite: ruclips.net/video/MkGQmZoMuRM/видео.html (includes connection.commit() which is very important!) It's not exactly MySQL, but it's right off the same alley 😉
10:23 shouldnt it be "strand1" inside the () brackets instead of dna_st1 ? sorry im easy to confuse xD. Also in the last line of the for-loop it should be b2 = "C" otherwise you can pair A with G
In the DNA example, to simplify the code, I would create a dictionary:
pair = {"A":"T", "C":"G", "G":"C", "T":"A"}
Then, instead of the nested if statements, do
dna = {key:[val, pair[val]] for (key, val) in enumerate(strand1)}
Agree, I felt a little excesive use of ternerary operatrors.
I think it should be .. pair[val]] .. but could be wrong.
@@colsadventures Yes it should, I've edited it now. 😳
Wow!! This looks awesome Katrina!! Great job! I love it! 😃😃😃
I've done it in a similar way:
dna = {idx:[b, {'A':'T', 'T':'A', 'C':'G', 'G':'C'}[b]] for (idx, b) in enumerate(strand1)}
The level of polish of the channel in general is really appreciated , thanks for sharing your knowledge !
The 'key' to learn dictionary comprehension is to practice this 'value'able exercises in this video.
hahahaha that was very poetic, Tom!! 😁
@@PythonSimplified Thank You 😊
I'm using this to teach a student about dictionaries, thank you!
I feel like dictionary comprehensions lose a little bit of its readability compared to a conventional loop once you start applying multiple conditions. Especially with group else statements rather than the traditional elif which (as you mentioned) doesn't exists within the comprehension.
But really nice to know about the feature as it never occurred to me that this existed.
I absolutely agree! I find that Comprehensions are much more comprehendible with lists hahahaha when it comes to dictionaries - the syntax becomes un-Pythonic very fast 😅
With that said, I use it way more often than traditional loops. I think I trained my brain to actually find it intuitive 🙃 hahahaha
@@PythonSimplified even if it looks less redable, i so much enjoy using a comprehenssion of everything, agree with you [x:=str(i)+str(i)[-1] for i in range(0,20,10)][1]+'%' 🙂
Excellent work! The clarity and didactics with which you have explained each concept are impressive. You have managed to break down complex topics into simple and accessible explanations, which is essential for deep understanding. Your ability to maintain simplicity without losing the essence of the concepts is truly admirable. Keep it up! Congratulations..
"Let's say that Spiderman is not exactly welcome in this DC dictionary" haha that was funny. I loved the examples.
hahahaha glad you like my humor Victor! thank you! 😃
@@PythonSimplified I concur. Using pop culture references not only makes things less tedious, but it really helps with comprehension. That's why this is my favorite coding channel. So many tutorials are just a monotonous voice on a bad mic with a screen recording of their IDE.
Also just wanted to say you're a really good teacher.
Great video, it is too clear.
A little variation of your code for the exercise #3:
users = ["mariyasha888", "KnotABot", "SpongiBOBO", "IAMBATMAN"]
keys = {
"id": lambda id: id,
"username": lambda username: users[username],
"password": lambda passw: "".join(random.choices(string.printable, k=8))
}
data = [{key:(val(i)) for (key,val) in keys.items()} for i in range(len(users))]
Maybe it's not the best way to do it, but it's just for practice 🙃. I'm learning python 😅. and your videos are very useful!!!
Many thanks for the great content. This should be archived for future data analysts and pythonistas.
First time it was overwhelming for me, but second time it was fun and I could understand it 100%. I need to implement this in real project before I forget it, Thanks a lot.
Thank you for this really good video. Definetly the last example was "WOW. I wouldnt be able to do it". Nice !!!!
Yeyyy!!! Super happy you liked it Danail! 😃😃😃
Hey Mariya
This video will help many💙🙃❤️
This real makes fun with dictionary comprehension for doing own private project
Mariya, Thank You for your very informative and energetic videos. Your videos are excellent and flow so well. Keep up the great work.
Requesting for a data structures and algorithm playlist
Will do! I'm waiting to finish my current Algorithms and DS 2 module in university before I can properly cover the topic 😉
(My final exam is in September, so not much longer to wait 😊)
@@PythonSimplified All the best for your exams mam!!
@@PythonSimplified Great, And all the best for your exams tho you gonna score 10/10 anyways
This was a really good tutorial showing more uses for comprehensions. Thanks!
Also, the addition of the slides showing the important notes was a really good add. That was very welcome.
Thanks again!
Thank you so much for the incredible feedback, Patricio! Super happy you enjoyed this tutorial! 😃😃😃
Amo a esta mujer! Enseña muy bien!
Tank you very much for the video . YOur explanations are awesome
Thank you for this video Mariya, it's really helped me in my journey
Very well explained! I like your videos. They help me better understand the Python language. Keep up the good work. 👍🙏
The most complete tutorial on DC. Can you please sware more on that
Wow that was great ,thank you..
My intuition tells me that range approach is faster, because zip approach must contain the procedure to compare between names and profs. Im a newbie for Python programming. Thank you for your videos, that help me a lot to learn Python.
Thank you so much for your comment Takeshi! 😃
I'm planning a live stream in which we will compare the two approaches! my intuition also tells me range() - however, with Python 3, the zip() approach is also very efficient so I'm expecting a very close battle 😉
Love the examples, thank you
Mariya, you can turn the password generator into a function call. And I also added a UID function as well. Great tutorial though. Thanks so much!
lists/dicts comprehension are constantly on that line where they are either great and easy to make and read or just long and ugly and make it harder to read so sometimes they are great, but sometimes it´s just better to do normal for loops
Thanks. Great video! I haven’t used dictionaries much yet, but I’ll come back to this when I do.
Thank you, Tim! 😃
Maria, thanks for the lessons. Almost everything is clear and without translation. zip is faster
As always the examples you choose are always related to my use cases.
Thanks a lot for the supper intuitive video.
That's awesome!!! Super happy I could telepathically guess the most useful examples! 😁😁😁
I'm a Mariya simp :) :) lol your videos are an excellent supplement to my college courses! Thank you for all your hard work!
A million thanks Maria, your explanation is very good
Excellent material and excellent educational exposition! Very well done!
Thank you Mariya. I found this very helpful and easy to understand.
This might be the best python tutorial I've ever found online. Thanks for sharing.
Thanks a lot! This content is very important for advanced python learn. 😃
Thank you so much Jefferson! I'm glad you found it useful! 😊
Best tutorial ever
Just helped me tackle my dictionary mental block.. Good stuff!
It’s really awesome thank you for the video
I became mad after watching this video. But you are a great tutor. I became a fan of you. Love you and your English. Thank you so much🧐😵💫🤒. I request you to please start a complete python tutorial for beginners.
Thanks a lot ! ❤❤. I was learned something from you. You are also better than my python profesor . U r taught something to me recent days . U r way speech and teaching is amazing itz easy to understand (but some topics are tough ) although u r videos are great 🥰
You are such a skilled teacher! Thank you
Will you please explain in separate video about how to read multiple elements from user at time using split function . 2. How to sort a dictionary without converting to tulle
I just discovered your channel and I've enjoyed following along with you. You are a great teacher! Thank you for all your hard work :)
Great tutorial I like very much. Thank you Mariya
your all videos are very very useful 👍
If it's just a simple code, go and use list/dict comprehension, but when you logic become more complex, you better write it the old way, it's lot easier to read. Just like lambda for simple function and not for complex function.
Thanks
You are a great teacher. Smart and beautiful
your explanation is very clear, thank you!
great video!! thank you. You're a super teacher about python, it's easy with you!! . 3:15 I Think zip is faster than len
Thank you so much for your comment David! We will compare zip() and range() in an upcoming live stream, we'll see exactly which of them beats the other 😉
Very Useful Thanks!
Super Enjoyed and Laughing !! 😀😀😀
Love the examples. Awesome content!
love your channel. Thank you for simplifying such valuable knowledge! Your delivery is on point.
amazing tips, thx for sharing !
Thank you so much!!!!
This is great. Thanks.
Hi, Sunshine ! 🌞😉👌
Very good !
Amazing! was looking forward to this video!! thank you thank you!!
Great teaching! Thank you!
I needed this video! Thank you stay awesome!
Nice Video THX , I just begin study dictionary
Awesome timing then! 😉
Best of luck with studying, Kais! 😃
@@PythonSimplified I try my best I very like Python and I love to learn it and U help me really 😄
beautiful... thanks.. .. I like your extra efforts to make these videos enjoyable with nice editing and awsome graphics
Cheers from México 💋
Lovely as always Mariya.
I would like to point out that using the random module isn't safe for generating passwords. People might use it to generate passwords for their various accounts online. You could mention the secrets module which is advised and secure. Anyway keep up the good work. Love you ❤️
Thank you so much for the awesome tip, TechieGuy! 😃
Secrets is indeed much more randomized than Random! the only issue is - I couldn't find a secrets.choices() method but rather secrets.choice() which returns a single value instead of k of them.
From my perspective, the last exercise seemed convoluted enough to avoid the additional list comprehension of:
password = "".join([secrets.choice(string.printable) for i in range(8)])
That's why I went for Random instead... however - if this was a dedicated video for random passwords I'd definitely use Secrets instead 😉
Very useful ! 🏆🏆🏆🏅🏅🏅Thank you very much !!! 🙏🤗
I feel the comprehension with the range function is faster🙃🙃.. cos range functions has less work load to perform than the Zip method.🤔
You can watch y playlists for Python and R, welcome !
12:55did u just said "neta" ?? xD awesome tutorial!
Awesome video, I've learnt a lot!! Thank you so much
Excellent.
1:07 why not use the dict constructor here instead of the loop?
dict_names_professions = dict(zip(list_names, list_professions))
any differences , benefits from using the loop?
I'm not a Python programmer, but I like your videos
Thank you so much Guilherme!! 😃 I might end up convincing you to start using Python... I have some really exciting projects in the making 😉
@@PythonSimplified Maybe I can use it in my projects too
This was an awesome tutorial 👍👍👍
I'd expect the "zip" method to be the faster one because it was purpose-made for such cases
and probably has some built-in optimizations, no?
Also the list comprehension where we add "man" works without putting (key, val) in brackets.
Trop forte cette merveilleuse dame
hello i m from indian yours warm well come i saw yours python video are very great i want learn python i think always may be one day i will learn python but money fees problem but my dream that learn python bcoz i saw python code is so lovely and easy for write and understand yes sue we can do with python code many great thing so my simple and hamble request from you can you teach to me python step by step from beginning thanq
Realy good video thanks a lot !
Thanks 😊
Wow, what a nice RUclips channel. Nice to see you, Mariya!
I think it would probably be faster to use the zip method. Two primary reasons, one being that with the range approach you have to check the list on each iteration, and two being since the zip function was probably programmed to do this efficiently it has a different method of accessing the objects. Just my guess!
very good very clever, very helpful.....but i rarely use these comprehensions and it would be faster for me to do it the long way than sit down to memorise the rules...then forget them.
Thank you^^ This is very helpful.
Wow, thanks dear
Wonderful video.
Happy teacher day mam
Password generation code (in my tests) may produce a string with one or more spaces. Used replace to get rid of those.
That was my original plan, Dimitri! 😃but then I thought to myself - what's the problem with spaces? I couldn't find a single reason why they would be any different from the rest of the characters 🤷♀️
Some sites do prevent you from using spaces within passwords - but I don't think it's based on merit. Do you find that space-less passwords are more secure?
Because string.printable contains whitespace \t,
,
, at first i used to cut it at the end when i imported it, but for me better aproach was change the original string module and create printable_ww same but without white space, i would like to contribute to open source to change that for python 3.12 if comunity accepts it
3:15 I think the zip approach is faster because the syntax is more comprehensive
please more video ...❤❤❤❤❤
NIce to see again - greets from Germany.
Thank you so much George Orwell! Huge fan of your 1984 book 😉 hahaha
Greetings from Vancouver! 😃
Thanks for another video if you can in the future make python with MySQL some mini project tnx. 😀
Hi Sem 😃
MySQL is definitely on my to-do list! will cover it in my Linux machine in future tutorials. In the meanwhile, you can checkout my SQLite tutorials:
⭐ SQLite Backend for Beginners:
ruclips.net/video/Ohj-CqALrwk/видео.html
(please note - the above tutorial is missing connection.commit())
⭐Web Scraping Databases with Mechanical Soup and Sqlite:
ruclips.net/video/MkGQmZoMuRM/видео.html
(includes connection.commit() which is very important!)
It's not exactly MySQL, but it's right off the same alley 😉
Great!
10:23 shouldnt it be "strand1" inside the () brackets instead of dna_st1 ? sorry im easy to confuse xD. Also in the last line of the for-loop it should be b2 = "C" otherwise you can pair A with G
I think the range approach is fastest.
well explained
Indeed your best! ♥
Thank you beautiful smart lady!
..great job Mariya. )) Which university did you attend that you reference at times? Do you teach somewhere? Again thanks. )))
🍓⭐high quality
Why are some of the passwords that are randomly generated more than 8 characters even though we used k=8?
really got stuck how we can put multiple values in the value ie [ value, if statemen], if you could further elaborate