Тёмный

Python TDD Workflow - Unit Testing Code Example for Beginners 

Python Simplified
Подписаться 230 тыс.
Просмотров 73 тыс.
50% 1

In this tutorial we will play the game of unit testing! 🎮🎮🎮
To do so - we will learn a brand new coding workflow, implementing a set of programming principles known as Test Driven Development.
I will introduce you to the Three Laws of TDD (also known as the Three Laws of Uncle Bob) and show how to write a piece of software unit by unit, test by test, 2 minutes at a time! ⏱️
The end result is not only a cool encryption algorithm known as Caesars Cipher - but also a series of unit tests that ensures its accuracy and reliability.
In the very end - I also have a 🏆 CHALLANGE 🏆 for you! So make sure you tune in at minute 23:10 to participate and practice your new set of skills! 💪
⭐ CLONE MY CODE ⭐
-----------------------------------------
app.wayscript.com/lairs/45150...
Also, please feel free to revise it and reshare your versions with the world!
Quick instructions of how to do this via Wayscript at minute 23:50
🚀 JUPYTER SYNTAX 🚀
-----------------------------------------
unittest.main(argv=[''], verbosity=2, exit=False)
📽️ RELATED TUTORIALS OF MINE 📽️
-----------------------------------------------------------------
⭐ Classes and OOP:
• Python Classes and Obj...
⭐ Inheritance and Private Class Members:
• OOP Class Inheritance ...
⭐ If _name_ == "__main__" for Python Developers:
• If __name__ == "__main...
⭐ List Comprehension:
• List Comprehension - B...
⭐ Software Design and Development Exam Practice Stream:
• Software Design and De...
⏰ TIMESTAMPS ⏰
-----------------------------------------
00:00 - Intro
01:19 - Three Laws of TDD
-----------------------------------------
TEST 1 - Test Data Exists
-----------------------------------------
02:07 - Basic syntax
03:59 - Jupyter Notebook syntax
04:30 - Assertion
06:28 - Production Code
07:32 - 2 minutes
-----------------------------------------
07:54 - Test Input Data Type
09:12 - Test Return Output
10:16 - Test Input and Output Length
11:45 - Test Input different from Output
14:28 - Test Output Data Type
15:46 - Test Caesars Cipher
20:40 - Test More Inputs
23:10 - Challenge for you!
23:50 - How to share your code via Wayscript
25:09 - Thanks for watching! :)
🤝 Connect with me 🤝
--------------------------------------
🔗 Github:
github.com/mariyasha
🔗 Discord:
/ discord
🔗 LinkedIn:
/ mariyasha888
🔗 Twitter:
/ mariyasha888
🔗 Blog:
www.pythonsimplified.org
🎯 Sources 🎯
--------------------------------------
⭐ Python unittest Documentation:
docs.python.org/3/library/uni...
⭐ Professionalism and Test-Driven Development by Robert C. Martin:
ieeexplore.ieee.org/document/...
💳 Credits 💳
----------------------
⭐ Beautiful animated graphics by:
mixkit.co
⭐ Beautiful icons by:
flaticon.com

Наука

Опубликовано:

 

2 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 138   
@jacobsoby3910
@jacobsoby3910 Год назад
Unit tests should never duplicate code or test inputs prior to the code running. The code should validate the input. The unit test should only test a known input vs. a known result, generally to highlight a corner case like the end of the alphabet in the Cesar Shift
@PythonSimplified
@PythonSimplified Год назад
Hi Jacob, thank you so much for your comment! 😀 Could you please share why it's the case that we should "never test inputs prior to the code running"? I've been looking into all the TDD materials I have from my university and I couldn't find anything that suggested it is forbidden. Is it based on your personal experience or can you share the resource that suggested it? If I'm demonstrating something that is indeed wrong, I need to know why it's wrong and whether it's opinion-based or factual before I issue a correction 🙃 Our industry has lots of conflicting views on different practices, even within the unit testing crowd there's huge disagreements between leaving in the tests in the production version or restricting them to the debug version only. In many cases both sides have compelling arguments so I try to avoid getting into grey territory. It would be awesome if you can elaborate on your comment a bit more! 😊 In terms of duplication, I thought I was avoiding it by utilizing the setUp() method. Did you mean duplicating the input I've passed from test to test? I might be wrong, but how I see it is: if my first 10 tests are dealing with a "banana" input - wouldn't it be considered duplication if I now copy all those tests just so I can apply them on "banana bread"? Please let me know! 😊 In terms of "only testing known input vs. a known result" it's sounds a bit like a black box approach, while UoL refers to unit testing as a glass box approach. I realize the real-life experience is different from theory, but shouldn't unit tests deal with the innerworkings within the production code too? My apologies about the long reply! I thought I understood TDD well, but your comment really confused me hahahaha 😅😅😅
@jacobsoby3910
@jacobsoby3910 Год назад
@@PythonSimplified The unit case is a special tool for regression testing. It's used to determine if new changes have affected a program, and you're right, you need to practice what I've come to know as "positive failure" (writing the failure messages in your code first). By testing your input inside your use case, you've robbed the application of sanitizing input and given yourself the false assumption that the program will not crash when fed invalid input. Your unit test should also feed invalid input to any code where you don't have complete control. For instance, if a user (or the program feeding the data to the encryption routine) feeds a blank string to the application, you would exit cleanly, but then the application has the opportunity to set something like "self.emptyStringFlag" For duplication of code: By using the same code in the unit test as in the actual application, you have no way of knowing if the bug is in one or the other. What was the original intent after refactoring? Is the calculation in the application correct, or is the calculation in the unit test correct? In the case presented in your video, I recommend using a known good input and a hand calculated result to compare... "ABCXYZ" and "BCDYZA" as hard coded in the unit test, that way there's no question as to what the expected result should be. Your setup method might populate a handful or more known values so your unit test can hit every "corner case" you know of, and be expanded on later (like adding the space character). Later, you might change the hard coded values into a file filled with many cases to detect known bugs you discover over time. Now keep in mind that if the program requirements change in the future (like adding a shift parameter), you would then have to update the unit test to reflect the changes These are not hard and fast rules, but rather great learning opportunities. I find that I have to step back and look at my own programs to see where I've pushed through a problem only to cause myself grief later. That's why we often refactor small portions of a program over and over until it's not only readable, but has a way to be maintained later. This is where unit testing comes in... it's easy to break a working program, but how would you know without a unit test? I do like that you have a passion for making these videos. I try to spend at least a half a day each week expanding my skill set, even when I'm busy working. Making tutorials is a great way to hone programming skills.
@PythonSimplified
@PythonSimplified Год назад
Jacob, your comment is absolutely incredible! You are reasoning about concepts that none of my lecturers bothered explaining or even discussing! I never even thought about flagging invalid input or about adding potential issues by duplicating parameters. In fact, I don't think I've ever had a conversation with someone who has so much hands-on experience with unit testing. I've always discussed it on a theoretical level, rather than focusing on how it translates into an appliable routine that developers use regularly. It's not enough to just utilize the unittest module, it's about having confidence in the reliability and accuracy of not just the production code - but the tests themselves and the inputs and outputs we use when conducting them. Thank you so much for taking your time explaining this, it makes perfect sense! I wish I spoke to you about this before filming my tutorial, I would have definitely changed a bunch of the content hahahaha 😅😅😅 I'm currently working on an article version of this video for my blog, which I'll definitely revise given you feedback, but I'm wondering if there's a chance I can quote parts of your comment in it? I'll create a bunch of quote section within the article and if you'd like I can include a link to you Github/Linkedin/etc. I think your experience with unit testing can help lots of aspiring programmers and I don't want to paraphrase you because I think you were spot on! Thank you so much one again, and please let me know if you are interested! 😀
@jacobsoby3910
@jacobsoby3910 Год назад
@@PythonSimplified You are very welcome. I'm happy to help. Feel free to quote or adjust the feedback to fit your style and content. Before lawyers got involved, there was a huge benefit from working cross-company with other developers. We would "borrow" ideas from one another and it wasn't an issue. I'll send you a PM with my info.
@PythonSimplified
@PythonSimplified Год назад
Yey! Thank you so much Jacob!!! The world was definitely much more simple before copyrights ruined it! 😉 You can find me at mariyasha888@gmail.com, I'll ping you when the article is ready (will probably take me some time to finalize it... I don't want to mess up again so I'll be extra picky 😅 hahaha)
@funkenjoyer
@funkenjoyer Год назад
I'm pretty sure this video was coming from a good place and was intended to shed some light on often ommited topic of writing tests. The problem is that it ended up being very very wrong in displaying how to do TDD (which btw a lot of ppl do hence why a lot of them hate TDD). I'd suggest looking at BDD which is pretty much TDD renamed to help developers avoid the misunderstandings that are floating around. So let me share a few things I've learned about tests after leaving uni (where they completely butchered that subject) First -> never ever write tests that test your implementation EVER, this will put you on a treadmill of spewing test that mean nothing and will force you to rewrite all of them whenever you make any change to your code Second -> dont test FUNCTIONS or CLASSES, test MODULES (and I dont mean module in how Python defines it but rather a module of our program) because the modules are actually the smallest UNITS we should be testing, anything smaller are just implementation details which can change over time so its pointless to write tests for them (since we would then need to change those tests), what should not change over time (or at least not frequently) is the INTERFACE of any given module so pretty much test WHAT the module is supposed to do not HOW it does it (aka treating the module as a blackbox) So in this case let's say our module is the CEASAR_CODE which has 1 function in it's interface ENCRYPT and what we want it to do is to take message and number and then return message where all of the characters were shifted by given number. And here is where the power of TDD (or BDD) comes in since we force ourselves to write the tests upfront we first have to think through WHAT we want our code to do and we'll think about the HOW later. Once we know what we want the code to do we can write tests that will check if it actually does it. 1. given string "abc" and number 2 check if encrypt returns "cde" - important to always give concrete examples (luckily we dont yet have any logic to copy paste) 2. given string of len 5 check if encrypt returns a string of len 5 These are quite the obvious ones but when you sit for a bit you start asking more questions like What should happen if the number is 1 -> should it be invalid input or just return the message as is Is empty string a valid input or not? What if the number given is negative? Maybe I want to be able to pass in the alphabet? What errors and when do I want it to raise (just the generic TypeError and ValueError or maybe some custom ones to better fit the problem) All of that makes you create a pretty strict set of rules that you want your code to follow and you end up with a test suite that checks if the test you written actually does what you wanted it to do (and not just what you told it to do which as we now is usually quite different from what we wanted :P) Which leads to the yet another part, once you have a suite like that it gives you confidence that those requirements you put in are safe, you can't brick your code during refactoring because the tests will tell you about it. And refactor you should, that's the last step of TDD which i feel was ommited here RED -> GREEN -> REFATOR (write failing test -> write minimal code to pass that test -> refactor that code)
@iammac5813
@iammac5813 19 часов назад
I learned more from your comment than this video . Thanks dude
@rugmaable
@rugmaable 10 месяцев назад
I have been learning the principles of software engineering for last 5 months, now with this new concept that was recently introduced , I was having a hard time grasping it. your video shed a light on a lot of concepts. Thanks for taking the time to explain to newbies like me.
@davidpimental6704
@davidpimental6704 Год назад
Thanks Mariya. Great video, as always! I appreciate the step by step approach. Not only is it good for learning unit testing, but development as well! :)
@marco.garofalo
@marco.garofalo 9 месяцев назад
I genuinely enjoyed your video on TDD and appreciate the depth you went into explaining each step. Your presentation style is quite engaging! That being said I couldn't help to notice several mistakes, so I hope I can provide you with some useful feedback: 1. Some of the initial tests went green/passed but there wasn't ANY production code written, you just added some code on the test itself to make it pass, which violates the TDD laws, the code to make the test pass HAS to be production code. Also you want to make sure that your tests are against the module/unit you are trying to validate/design, in this case it doesn't make much sense to test the "input", you want to focus your test against the encrypt function. 2. The last test you wrote was very tightly coupled to the implementation details of the solution, it basically validated that "1 + 1" equals "1 + 1", sort of a tautology. As a matter of fact, in order to make the test pass you had to fix the production code AND then replicate the fix on the test, a bit of a red flag. Tests should be more like "validate the expected output is equal 2", so that you are free to implement it as "1 + 1" or "1.2 + 0.8" and then in the future change it to "0.5 + 0.5 + 1" (you get the idea), so the test is resistant to refactoring and not prescribing a specific implementation. 3. You had the right mindset from the outset, i.e. divide and conquer and proceed incrementally to build a solution, but then you sort of dropped the whole logic into the last test with no increments whatsoever, you should have split that test in many many cases: e.g. "shift letters by one", "deal with numbers also", "deal with spaces/other-chars" etc. 4. The 3 steps of the TDD cycle include a refactoring phase after the green phase (Red-Green-Refactor), and is a very important one, because that's were we can make the code more readable, clean, well-designed and what not, for instance the logic for the encryption function felt like a good candidate for refactoring. Just to be clear, refactoring can be applied to both production and test code. 5. You kept changing the single message "manually", but what you actually should have done is to codify those manual steps into test for those boundary conditions, so that they can catch regressions in case somebody (you included) modify the code in the future. I'd recommend watching this talk by Ian Cooper, probably one of the best talks out there which goes over the common TDD misconceptions: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-EZ05e7EMOLM.html All in all, I really appreciated the effort, don't worry too much about the mistakes, we've all made the same mistakes throughout our own TDD learning journey, so keep practicing!
@ort1340
@ort1340 Год назад
I'm so happy you did this video, helped a lottttttt ,just needed a unit test for my project Thanks again for your lovely content 😊
@PythonSimplified
@PythonSimplified Год назад
Yeeeeey! super happy I was able to help! 😀😀😀 Thank you so much the incredible comment, Or! 😊
@ojarikreegbenine7757
@ojarikreegbenine7757 8 месяцев назад
Thank you for this lesson on unit testing for beginners. It was very clear and comprehensive!
@saami9606
@saami9606 Год назад
I love your personality! You defo make learning python alot fun!
@richi1235
@richi1235 Год назад
Couple of decades as a deveoper under my belt and i have NEVER seen TDD actually applied in production. I meet lots of people who think it is a god idea, but nobody seems to actually use it, its hilarious.
@PythonSimplified
@PythonSimplified Год назад
hahahaha I think it's mostly an academia thing... if my university didn't cover it - I wouldn't know anything about it! 😅 I don't think I'll be using it for my personal projects as it's very time consuming, but I can see how it results in a more-reliable piece of software. You basically have more confidence in your code and its boundaries - but it comes at the expense of your time 😉
@testingcoder
@testingcoder Год назад
I use TDD for production development. In fact there are even companies which primarily develop software using TDD.
@retagainez
@retagainez Год назад
@@PythonSimplified It might seem like only an academia technique, but it is a very wise way of developing code from scratch.
@molohktegg2462
@molohktegg2462 8 месяцев назад
I’ve been developing for a living for 25 years and I do TDD every day. My flow is design using diagrams, code empty structures (classes or functions depending what I’m working on), then do tests based on the main paths, then code until all tests pass, and then add edge cases. I do little refactoring when building new code because I spend much time designing.
@tiamabderezai5374
@tiamabderezai5374 Год назад
The first sentence of your video is a great analogy, well said.
@PythonSimplified
@PythonSimplified Год назад
Thank you so much Tiam! :)
@CurrentElectrical
@CurrentElectrical Год назад
Love it! Excellent Tutorial. We now have snow in Ontario. I hope all is well. Play safe. :D
@paulthomas1052
@paulthomas1052 Год назад
Great introduction to unit testing. I really enjoy your content. Thanks.
@PythonSimplified
@PythonSimplified Год назад
Thank you so much Paul! 😊
@felex777
@felex777 6 месяцев назад
Thanks for a video! It was handy for my project.:)
@hiutale
@hiutale Год назад
Amazing! Thank you~~~ ✨
@jeuxmathinfo9578
@jeuxmathinfo9578 Год назад
Very useful !!! Thank you so much !!! 🙂
@CrazyFanaticMan
@CrazyFanaticMan Год назад
Please more QA tutorials, this is what I am missing from my toolbox I've already mastered automation, now I need to learn things like TDD and BDD and son
@PythonSimplified
@PythonSimplified Год назад
Absolutely! Will do, CrazyFanaticMan! 😉 Please checkout the pinned comment by Jacob, you'll learn so much from it! I'm a computer science student so my perspective is very theoretical, but if you'd like to learn the hands-on approach - please checkout the more critical comments, as they point out a few problems within my code that students may not notice but professionals see right away! 🙃
@techwithdavid
@techwithdavid Год назад
Yet another great video👍
@PythonSimplified
@PythonSimplified Год назад
Yeeeey! Thank you so much David, glad you liked it! 😊😊😊
@diwakar_tsn
@diwakar_tsn Год назад
As always best video 😉❤️
@PythonSimplified
@PythonSimplified Год назад
Glad you liked it! (despite not having any JavaScript involved hahaha) 😀😀😀
@blevenzon
@blevenzon Год назад
Every video you make and I watch (they are amazing btw) it proves exactly how dumb I am
@KadirMedia
@KadirMedia Год назад
Very nice tutorials, channel and a charming teacher . I recommend subscribing
@Tobs_
@Tobs_ Год назад
good stuff, thanks Python Lady. I had a practice Python test earlier for a job, and another tomorrow. It has been so long that I could barely remember the syntax 😀
@PythonSimplified
@PythonSimplified Год назад
Thank you so much Tobs! Good luck with the Python recap! 😀 I always have a similar problem with remembering JavaScript, I keep using "for 0 < i < 4:" instead of "for (0 < i < 4){}" for the first few hours of getting back to it 😂😂😂
@Tobs_
@Tobs_ Год назад
@@PythonSimplified just finished the test but I failed, I had to sort a dictionary but I wanted to sort by the values and then return the keys. Python refused to sort by the values. I was thinking of another way when it said I had 9 seconds left 😥
@PythonSimplified
@PythonSimplified Год назад
@@Tobs_ oh no Tobs! I'm sorry to hear that! 😭😭😭 sounds like something that dictionary comprehension could have helped with, or maybe even converting the ductionary into a Pandas Dataframe to make it more convenient to sort. That's why I don't like this timed test-based approach to hiring! When the clock is ticking and so much is on the line - they miss out on many talented candidates! 😡 fastest approach is not always the best approach, it's not a way to evaluate skill. "It works" rather than "it works well"... I would imagine that ones portfolio on Github is a mich better indication of talent than a one-time test 🙃
@Tobs_
@Tobs_ Год назад
@@PythonSimplified thanks mate, no worries, I still have a job so not as bad as when I was unemployed. I was just hoping to get a different experience, but sometimes the code goes your way, and sometimes it doesn't. I think the solution was sorting the dictionary on values somehow, setting a lambda key on the sorted() method probably. I just needed another 3 or 4 minutes, but when your time is up, your time is up.
@Tobs_
@Tobs_ Год назад
sortedWeights=sorted(weights.items(),key=lambda tup: tup[1], reverse=True) list=[] for v1,v2 in sortedWeights : list.append(v1)
@sarc007
@sarc007 8 месяцев назад
Wonderful!!!
@pablomartinez1504
@pablomartinez1504 Год назад
Hey Mariya, what are those cool projections and lasers you have on you set-up?
@Mralex22801
@Mralex22801 Год назад
Amazing 🤩
@mirazhran77
@mirazhran77 10 месяцев назад
you are great teacher mariya
@juliuswanyama
@juliuswanyama Год назад
Excellent ❤
@PythonSimplified
@PythonSimplified Год назад
Thank you Julius! 😀
@benedekborbely9803
@benedekborbely9803 Год назад
Could we spare the "if-else" and make it branchless with modulo?
@MrPioneer7
@MrPioneer7 Год назад
Thanks a lot 👍
@PythonSimplified
@PythonSimplified Год назад
Absolutely! enjoy! 😊
@martinlutherkingjr.5582
@martinlutherkingjr.5582 4 месяца назад
The wayscript link to the code no longer works. Is the code available somewhere else?
@Alikhan-ee7bs
@Alikhan-ee7bs Год назад
Today I enjoyed your videos on cryptography. But for security encryption techniques divide into symmetric and asymmetric encryption etc.
@PythonSimplified
@PythonSimplified Год назад
One of my favourite computer science topics is cryptography! I would LOVE to start covering it on the channel 😀 I'm hoping to see lots of comments saying "Mariya please cover more encryption algorithms" as I think I can simplify RSA and hashing really well! 😉 I'll probably start with more symmetric stuff (probably the cipher from Edgar Allan Poe's Golden Bug) but the goal is definitely the highly complex asymmetric algorithms we use nowadays (everything else is interesting, but quite useless hahaha 😅😅😅)
@bc4198
@bc4198 Год назад
@@PythonSimplified Mariya please cover more encryption algorithms 😀
@beckaksel8783
@beckaksel8783 Год назад
Hello, I love your videos about kivy)) I have a question: I will develop a mobile app and upload it to the Google Play. What do you think, can I use kivy or it is better to use java? Thank you)
@PythonSimplified
@PythonSimplified Год назад
I believe you can do that with Kivy, just make sure your .apk file is fully operational before you apply 😊 On the other hand, Java/Kotlin is a bit more conventional when it comes to proper Android apps. Kivy is great for creating quick and simple mobile apps, but if you're building something a bit more comprehensive - I would definitely go the Java way instead 😉 Best of luck with your app! 😀
@abhijitkalita6931
@abhijitkalita6931 Год назад
Great 👍👍
@PythonSimplified
@PythonSimplified Год назад
Thank you Abhijit! 😀
@julianmahler2388
@julianmahler2388 21 день назад
22:19 If you keep copying your function code to the unittest section and back, isn't it to be expected that the output will be the same? I mean, you're basically testing if 2+2 equals 2+2 instead of 2+2=4. Wouldn't assertIsEqual(encrypt('banana'), 'cbobob') make more sense?
@faaiidodiineed6924
@faaiidodiineed6924 Год назад
Hi teacher, I developed a small system in tkinter and it is fine without any error, my question is: How can i let it play a music when executing and closing? Thank you
@PythonSimplified
@PythonSimplified Год назад
I think the easiest way to play music (.mp3 files in particular) with Python is via Pygame! 😊 I have a repository on Github that might help you with that: github.com/MariyaSha/PythonMusicPlayer If you're more into .wav files, checkout: ⭐ simpleaudio: simpleaudio.readthedocs.io/en/latest/ ⭐ or the Tkinter based tkSnack (I don't think it's officially by Tkinter, but it should be compatible): www.speech.kth.se/snack/man/snack2.2/python-man.html Best of luck with your app! 😁
@polyliker8065
@polyliker8065 Год назад
One of the uses of testing is that we can get clarity of why things go wrong. To get clarity we want to watch out for tests that test too much at once. Too much (strictly speaking) is more than one real case at a time. If we test too much in the same case it becomes unclear why the test failed. In this example if we only tested a string that is made of all characters including characters not in the abc then we could fail because of a number of reasons. Maybe it was one of the characters not included in the abc variable (no clue which one), maybe it was because we hit an index out of bounds for the last character, maybe the characters do not map correctly, maybe it was because we're using a combination of abc included and non included characters (or maybe my pc just refuses to compute anything untill it gets some coffee). The point is that we don't get much of an idea why our test failed. Sure we can open a debugger and go though it but it is much nicer (as in quicker and less mindnumbing) if we can isolate the issue with a testcase since we can then quickly and clearly see what makes the issue occur.
@PythonSimplified
@PythonSimplified Год назад
Sometimes the coffee part is what actually went wrong with the PC hahahaha 🤪🤪🤪 I definitely agree with you Poly Liker! 😊 I've created this tutorial based on theoretical knowledge rather than hands-on experience. You can checkout the pinned comment where Jacob explained some of the points you've mentioned very thoroughly, I believe you guys are on the same page! 😉 I think it's very important to reason about these concepts, as folks who are just beginning their Unit Testing journey (such as myself) are rarely exposed to these type of conversations. We see a coding example by our teacher/lecturer, we think we understand everything, but when it comes to implementing unit testing on our own - we just repeat what we saw, which was a very specific and narrow example, without thinking deeply about the process and how it manifests in different situations. I'll just keep practicing and when I'm confident enough - I'll make another attempt at covering this concept on the channel... this time properly! 🙃
@soukron
@soukron Год назад
15:15 hahaha love it!
@soukronfpv
@soukronfpv Год назад
@PythonSimplified take a look to that spam!
@soukronfpv
@soukronfpv Год назад
watch out, some spam is trying to impersonate you.
@super7ace
@super7ace 11 месяцев назад
Beauty with brains ;)
@ojaimark
@ojaimark 10 месяцев назад
It looks like wayscript has shut down. Do you happen to know of any similar platforms? I'm only now hearing about it and it seems like a really cool idea.
@gfoork324
@gfoork324 Год назад
what wallpaper you using at 1:06 if its any sort of wallpaper eninge please send me link and also what monitor do you use
@PythonSimplified
@PythonSimplified Год назад
It's the Aura ROG Wallpaper, I install it via an application called Armoury Crate (it's an Asus ROG control panel) 😀 Monitor is Samsung Odyssey G9 (they came up with a newer version since, once that can be turned vertically) Hope it helps! :)
@gfoork324
@gfoork324 Год назад
@@PythonSimplified thank you 💗
@JackySupit
@JackySupit Год назад
great tutorial. anyway about 21:41, I just want to share a little cool trick. Instead of writing if else, you can just write it like this (it's applicable on any programming languange): abc[(abc.find(char) + 1) % len(abc)] for idx, char ... pretty cool right :)
@arochomsky9254
@arochomsky9254 Год назад
this trick is also good when you have to check if a list is just another list rotation.
@PythonSimplified
@PythonSimplified Год назад
Thank you so much for the great tip, Jacky! I'm huge fan of modulo! definitely a better alternative! 😀😀😀 It's just a bit more complex to explain to folks who are not very experienced with programming or math (and the video was long enough already hahahaha 🤪). Conditional statements are not nearly as cool, but since they were covered in my List Comprehension tutorial - I went for one instead :)
@carlosrivadulla8903
@carlosrivadulla8903 Год назад
pls can u conver the now built-in "tombllib" module? looks far prettier, simpler and more readable format than csv or json.
@PythonSimplified
@PythonSimplified Год назад
I haven't had a chance to look into TOML files yet so I don't really know much about it at this point of time 🙃 If I see more requests I'll definitely check it out! Thank you so much for your suggestion, Carlos! 😀
@relytheone853
@relytheone853 5 месяцев назад
How can I work for a company by learning from your videos?
@elcanbayramli4444
@elcanbayramli4444 Год назад
Hi, Where to get that live bachkgrounds?
@PythonSimplified
@PythonSimplified Год назад
It's the Aura ROG Wallpaper, I install it via an application called Armoury Crate (it's an Asus ROG control panel). I'm pretty sure you can use it even if you don't have any ROG parts 😀
@TechNetworkz
@TechNetworkz Год назад
She is so awesome
@Alikhan-ee7bs
@Alikhan-ee7bs Год назад
I enjoy it when I apply cryptography in real life for example internet of things IoTs security cybersecurity and block chain etc.
@PythonSimplified
@PythonSimplified Год назад
Ali, why do I have a feeling you're using Kali Linux as your operating system? 😉 (me too!! but on my laptop though hahaha)
@Alikhan-ee7bs
@Alikhan-ee7bs Год назад
@@PythonSimplified i am using Linux for cryptography
@yolow8126
@yolow8126 Год назад
Hi iam a sub. How do you do these Thing is there any suggestion for book for python,ml,dl And data scince
@PythonSimplified
@PythonSimplified Год назад
Hi Yo! :) I rarely read books as I mostly learn by example, but my university (UoL) works with: ⭐ Python for Data Analysis by Wes McKinney In terms of Machine Learning, checkout: ⭐ Deep Learning with Python by Francois Chollet I've read a bunch of it, and it's highly recommended by a long time subscriber of this channel (S M Ali) 😀
@blankbox3403
@blankbox3403 Год назад
Hello 👋👋👋 Please make a video on how to connect kivy with emulator to check how our apps look on mobile device
@PythonSimplified
@PythonSimplified Год назад
Thank you for your request, Morgan Freeman! hahaha I'll get back to covering Kivy soon, will definitely keep the emulator in mind! 😉
@raivisrasnacs1088
@raivisrasnacs1088 Год назад
I prefer pytest due to its non-oop nature. It's much easier to understand without prior oop knowledge.
@PythonSimplified
@PythonSimplified Год назад
I haven't had a chance to work with Pytest yet, but I did get a bunch of recommendations on it! 😉 Will check it out shortly, thanks for suggesting! (I must admit thought - I'm a huge fan of OOP hahaha)
@undeadpresident
@undeadpresident Год назад
I landed a segfault! woohoo!
@beluv
@beluv 7 месяцев назад
Flashbang warning at 4:14
@triggy60
@triggy60 9 месяцев назад
why my first law return ok ?
@elvendragonhammer5433
@elvendragonhammer5433 Год назад
Like your content , you always make it interesting! I didn't get to see your last vid till today, & so I don't know if you'll see this- or if ur into gaming or not, but I thought I'd mention a few programming type games u might like. (newest 2 oldest) {All are available on steam} Robo Co. (it's a robot building/coding game that lets you use actual python script in game to program / enhance your creations ;) Autonauts vs Piratebots Autonauts (Use Obj & code-block style programming to automate tasks for your robots to ultimately create an autmated metropolis for the human colonists) Nimbatus (design & build your own ships & ultimately create & program dromes to mine asteroids & planetoids autonamously) Factorio (More of a factory building/manufacturing game @ the outset but later you can program drones, train loading/unloading/delivery & tons of other stuff. I have seen some one program the equivelent of an A.I. to decide where to & how to, deconstruct their current base & rebuild it section by section in a new location while fending of enemy attacks without any human intervention.) Space Engineers (the oldest of these- it came out in 2013 has low system specs but still looks nice- & still has new content releases every few months. It could be considered as a cross between Lego Designer & No man's Sky, Eve Online & the X- Series ) It lets you build & program ships, space stations, make ammunition, weapon, mech, or cruiser class+ ship factories that u make fully automated right down to what info from what components, sensors etc get diverted to what in-game display screens, lights doors etc.& then ship them to stations or the frontline for other factions/players to buy) This one is currently on sale for 50% off all versions & DLC I picked up the Space Engineers Ultimate Edition ($34.44 w/tax) It includes: Space Engineers, Space Engineers - Deluxe, Space Engineers - Decorative Pack #1 & #2, Space Engineers - Style Pack, Space Engineers - Economy Deluxe, Space Engineers - Frostbite, Space Engineers - Sparks of the Future, Space Engineers - Wasteland, Space Engineers - Warfare 1, Space Engineers - Heavy Industry
@PythonSimplified
@PythonSimplified Год назад
I'm definitely into gaming! You've seen my PC hahahaha 😉 Thank you so much for recommending! I'm more into shooters like The Division 2 or open world games like GTA and Red Dead Redemption 2 - but will definitely checkout Space Engineers, looks very promising! 😀
@elvendragonhammer5433
@elvendragonhammer5433 Год назад
@@PythonSimplified Honestly didn't think u'd read my post- two others you might like are From the Depths & TerraTech they are much more open world then the prior ones I mentioned. Hope you have a blast! 🤖
@krishagrawal6753
@krishagrawal6753 Год назад
chr(ord(char) + 1) would be much better ig
@PythonSimplified
@PythonSimplified Год назад
Wow!!! What a fantastic solution, Krish! absolutely brilliant!! thank you so much for sharing! 😀😀😀 This skips fetching the alphabet altogether!!! I wish I thought of that!!! 😉 Please check it out folks: message = "banana" encrypted_message = "".join([chr(ord(char) + 1) for char in message]) print(encrypted_message)
@krishagrawal6753
@krishagrawal6753 Год назад
@@PythonSimplified lol yea...
@solotron7390
@solotron7390 Год назад
I think you mean: chr(ord("A")+((ord(char)+1)-ord("A"))%26) which would work for all uppercase letters, not just "A" through "Y", as "Z" fails.
@Whatthetrash
@Whatthetrash Год назад
This is fantastic! Though 'z' becomes '{' (not 'a') and 'Z' becomes '[' (not 'A'), everything else works. Fantastically succinct idea. :)
@manuelr7121
@manuelr7121 Год назад
i found another youtuber that you would make a perfect couple with !!
@PythonSimplified
@PythonSimplified Год назад
Too late, Manuel! I'm already engaged to the man of my dreams! 🤩🤩🤩 (he's far from being a RU-vidr hahaha)
@firiasu
@firiasu Месяц назад
I've been watching you for a few seconds and already fell in love ❤❤❤
@ScottzPlaylists
@ScottzPlaylists Год назад
Looking forward to more AI stuff....
@PythonSimplified
@PythonSimplified Год назад
I'm working on a brand new AI Simplified series (while on vacation) 😃 a bunch of absolutely incredible tutorials are coming soon, so please stay tuned! 😉
@cezartorescu
@cezartorescu 2 месяца назад
Nice approach, but you do know you shouldn't write list comprehensions that are very complicated. You should respect PEP8 also.Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated. Flat is better than nested. Sparse is better than dense. And most important ....readability counts.
@agentm10
@agentm10 6 месяцев назад
I hate TDD with a passion! I recognize how important it sounds, and blackbox testing is great, but in my opinion TDD leads to far more complicated sphagetti code cause your sole aim is to satisfy a test. Just take a look at the final code in this video. It takes a nice clean algorithm and makes it almost unreadable. Also, as others have pointed out, the implementation in this video has some issues. I would even go as far as to say that you never tested for the existence of the encrypt function, went straight to it's output, this breaking a TDD law (OK, this is a bit of an exaggeration, but so is my annoyance with TDD). Anyways, still a great video!
@Super1234casper
@Super1234casper Год назад
Sorry to say but that List Comprehension breaks my heart. It is way to long and has to much complexity. When you add too much complexity to a list comprehension the readability goes down significantly, so next time just use a normal for loop. Try to follow the PEP-8 or the Black standard. If you follow one of these standard the maximum line length is 79 for PEP-8 and 88 for Black.
@PythonSimplified
@PythonSimplified Год назад
On no! I didn't mean to break your heart GredField!! 😊 The thing is... List Comprehension has a HUGE benefit over for loops in terms of speed! Checkout the beginning of my zip vs. range live stream where we compare the benchmarks, I think you'll be very surprised to see how much difference it makes: ⭐ ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Otr6BW-uKFs.html In the end - it's all a matter of personal preference. If readability is more important to you than execution speed - you should definitely go for a for loop! If functionality/time resources is more important to you - than List Comprehensions is a better way to go! I don't think there's ever a one-size-fits-all solutions when it comes to programming 😀 Since it's such a dynamic field that changes and develops overtime - I don't know if restricting yourself to a pre-defined set of rules that somebody else wrote for you is the best way to explore Python to the fullest extent. I think it's more than OK to experiment with "unconventional" routes. I mean - how would we ever invent or discover something new if we keep repeating somebody else's practices? 😉 That's just how I see it... it might not work for everyone, but that my take 😁
@lonely9183
@lonely9183 Год назад
You are so pretty
@PythonSimplified
@PythonSimplified Год назад
Thank you dear! 😊
@osacaos
@osacaos 10 месяцев назад
when a beautiful women tech you something it becomes v easy to understand thank you please mor videos
@clementfauchere3528
@clementfauchere3528 Год назад
How often in real life do you have to deal with a problem that is as trivial as this one? Those are overused school cases and are completely agnostic to reality.
@PythonSimplified
@PythonSimplified Год назад
When you learn something new you need a simple starting point, you can't just jump on to a super useful startup idea right away! 😉 Once you understand the general concept - you can then implement it on more complex real-life projects and take this skill to the next level. I try to focus on helping people, in particular beginners, understand ang gain confidence + motivation on their programming journey. I've called my channel Python Simplified for a reason (otherwise it would be called Python Professional or something along these lines hahaha 😅)
@retagainez
@retagainez Год назад
@@PythonSimplified I thought the example was sufficient, but a little too trivial which led you down a few misleading paths :)
@deeplazydev
@deeplazydev 11 месяцев назад
Definitely this does not apply to C++, your test app won't compile. The workflow requires much more work. At work we do not apply it.
@diconicabastion5790
@diconicabastion5790 Год назад
I can sum up why I hate unittesting and tdd in one example. Guy comes to me with his code. He can't figure out why it keeps failing the test. So I check his code and there isn't an issue with the stuff we needed. So I look at the unit test. It was the test that was bugged he wrote. See the stupid part about unittesting is they forget the test itself is just more code that may need debugging. So what are you going to do write another test to make sure the unittests aren't bugged. Well maybe that code is bugged so you should write more stupid test to check it. TDD results in programs that can in some cases perform a function well but it doesn't work well when you are trying to develop software to do what someone wants or needs. It also just bloats adds way more work. 35 years I have never gotten a single thing useful out of it. So I never used it myself. I won't work for an employer that demands me to use it so never had to myself. But I've held other people over that time with their code like the example above and it has only been problematic never once useful. If you want to do testing do it at a system or functional level. Even I do that. Lets say I am writing a compiler. I won't test at minor levels of code like you are showing. I have base code I have used for decades I know works so unless there is a compiler or hardware issue there is no point testing it till the end. I'll write something on the level of the interpreter or assembler and test it. Or I've been working with game engines a lot in the last decade as well. You can break those into parts like graphics engine, physics engine, sound, resource manager and so on. I test at those levels. Just to be clear I hate bloated code I'm a minimalist and performance junkie. I like small code the less there is the better. Two reasons it will usually perform better secondly there is less to debug if there is an issue. I can get it done faster if you need a 3rd reason. Kent Beck tells why TDD worked for him. He says in a video he had trouble focusing on larger problems at once. He has anxiety issues and wanted a way to be confident in his code working. To bad he didn't realize his unit tests are also code and what if he wrote those wrong? I think while someone is in college just learning to program it could be helpful to some. I don't belief it should ever be used in a business or production environment. Most my programming has been in the industrial fields power plants nuclear, chemical plants, fabs, ... Not once in that time has my code been linked to a failure or incident. If it had it would have cost lives. So I wasn't worried at the end of the day like Kent Beck if my code worked I cared if I got someone killed or not.
@PythonSimplified
@PythonSimplified Год назад
Wow!! Thank you for the incredible input that none of my university lecturers dared to share! 😀 We write all those fancy tests, we pass them and we think our code is flawless as a result - but what if our tests are flawed?? 🤯🤯🤯 I absolutely agree! I don't have nearly as much experience in the field - but it makes perfect sense! Testing comes in many shapes and forms, unit testing is just one of them and while it is presented as a common practice by universities and collages - it seems to have very little real-life applications. It might work well for a certain type of developers, but it is very time consuming and just as prone to errors as the traditional coding approach. You're not gonna hear that from my lecturers that's for sure! Otherwise we'd just pass the exam and forget all about it 😉 Thanks again, Diconica Bastion! I really appreciate you took the time to share your experience with us!
@ChuckNorris-lf6vo
@ChuckNorris-lf6vo Год назад
Don't do anything without Copilot do not waste time.
@PythonSimplified
@PythonSimplified Год назад
If Chuck Norris said it - it can't be disputed! 😉
@3dprofessor520
@3dprofessor520 Год назад
Im sick and tired of windows.
@1over137
@1over137 Год назад
The first test you wrote is NOT a unit test. It does not test anything, there is nothing under test, it's 100% totally and utterly pointless. You would have been better off obeying Rule.2 by putting pass() in the unit test.
@PythonSimplified
@PythonSimplified Год назад
Checkout the pinned comment Paul, we've already discussed it with Jacob 😀
@3dprofessor520
@3dprofessor520 Год назад
Boycot windows. Its all BS.
@AEfsaenti
@AEfsaenti Год назад
красотка)
@PythonSimplified
@PythonSimplified Год назад
Спасибо большое! 😊
@aasifkhan1545
@aasifkhan1545 Год назад
Enter your secret message: banana Enter your secret code: -100 output: 76i6i6 is this answer correct I don't know but this video help me solve so many problems
@djladieslove1
@djladieslove1 Год назад
Prof You know I was having a hard time installing QT 5 on the iMac the other day 🥲
@brettdbrewer
@brettdbrewer Год назад
drive.google.com/file/d/1ocd9KNNO7QCPt2HjIpBO-5ULfI5-8oNj/view?usp=share_link I had to see if ChatGPT could solve this relatively simple algorithm. It went the ord() route, but it fails on negative shifts and shifts outside the length of Unicode (doesn't wrap). Its explanation is also wrong as it says non alphanumeric characters will not be shifted, but they are by the program. I've found something like "encrypted_message += abc[(abc.find(char) + shift) % len(abc)]" is concise and works nicely for positive shifts, negative shifts, and shifts larger than the set of characters you use (ie it wraps).
Далее
Super sport😍🔥
00:14
Просмотров 2,6 млн
If __name__ == "__main__" for Python Developers
8:47
Просмотров 376 тыс.
How To Create Decorator Functions In Python
4:59
Просмотров 1,5 тыс.
25 nooby Python habits you need to ditch
9:12
Просмотров 1,7 млн
Pytest Tutorial - How to Test Python Code
1:28:39
Просмотров 153 тыс.
5 Useful Dunder Methods In Python
16:10
Просмотров 49 тыс.
Cloud Computing for Beginners - The Ultimate Guide
21:34
SAMSUNG S23 ULTRA🔥
0:47
Просмотров 146 тыс.
Полезные программы для Windows
0:56