Python TDD Workflow - Unit Testing Code Example for Beginners

  Рет қаралды 80,372

Python Simplified

Python Simplified

Күн бұрын

Пікірлер: 139
@jacobsoby3910
@jacobsoby3910 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@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 2 жыл бұрын
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 2 жыл бұрын
@@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 2 жыл бұрын
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)
@marco.garofalo
@marco.garofalo Жыл бұрын
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: kzbin.info/www/bejne/e4uTZphterKCgq8 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!
@richi1235
@richi1235 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
I use TDD for production development. In fact there are even companies which primarily develop software using TDD.
@retagainez
@retagainez 2 жыл бұрын
@@PythonSimplified It might seem like only an academia technique, but it is a very wise way of developing code from scratch.
@rugmaable
@rugmaable Жыл бұрын
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.
@amventures1
@amventures1 Ай бұрын
in last test, you could also add % 94, to prevent out of index error. So, when you are on the last character of abc, it will take you to abc[0] as len(abc) is 95
@anandsrikumar007
@anandsrikumar007 4 ай бұрын
Best video on unittest ever, so beautifully explained. Thank you
@CrazyFanaticMan
@CrazyFanaticMan 2 жыл бұрын
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 2 жыл бұрын
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! 🙃
@tiamabderezai5374
@tiamabderezai5374 2 жыл бұрын
The first sentence of your video is a great analogy, well said.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you so much Tiam! :)
@ojarikreegbenine7757
@ojarikreegbenine7757 Жыл бұрын
Thank you for this lesson on unit testing for beginners. It was very clear and comprehensive!
@ort1340
@ort1340 2 жыл бұрын
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 2 жыл бұрын
Yeeeeey! super happy I was able to help! 😀😀😀 Thank you so much the incredible comment, Or! 😊
@saami9606
@saami9606 Жыл бұрын
I love your personality! You defo make learning python alot fun!
@polyliker8065
@polyliker8065 2 жыл бұрын
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 2 жыл бұрын
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! 🙃
@Tobs_
@Tobs_ 2 жыл бұрын
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 2 жыл бұрын
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_ 2 жыл бұрын
@@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 2 жыл бұрын
@@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_ 2 жыл бұрын
@@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_ 2 жыл бұрын
sortedWeights=sorted(weights.items(),key=lambda tup: tup[1], reverse=True) list=[] for v1,v2 in sortedWeights : list.append(v1)
@julianmahler2388
@julianmahler2388 6 ай бұрын
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?
@CurrentElectrical
@CurrentElectrical 2 жыл бұрын
Love it! Excellent Tutorial. We now have snow in Ontario. I hope all is well. Play safe. :D
@felex777
@felex777 11 ай бұрын
Thanks for a video! It was handy for my project.:)
@blevenzon
@blevenzon 2 жыл бұрын
Every video you make and I watch (they are amazing btw) it proves exactly how dumb I am
@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! :)
@JackySupit
@JackySupit 2 жыл бұрын
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 2 жыл бұрын
this trick is also good when you have to check if a list is just another list rotation.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
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 :)
@paulthomas1052
@paulthomas1052 2 жыл бұрын
Great introduction to unit testing. I really enjoy your content. Thanks.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you so much Paul! 😊
@Alikhan-ee7bs
@Alikhan-ee7bs 2 жыл бұрын
Today I enjoyed your videos on cryptography. But for security encryption techniques divide into symmetric and asymmetric encryption etc.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
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 2 жыл бұрын
@@PythonSimplified Mariya please cover more encryption algorithms 😀
@faaiidodiineed6924
@faaiidodiineed6924 2 жыл бұрын
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 2 жыл бұрын
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! 😁
@pablomartinez1504
@pablomartinez1504 2 жыл бұрын
Hey Mariya, what are those cool projections and lasers you have on you set-up?
@mirazhran77
@mirazhran77 Жыл бұрын
you are great teacher mariya
@beckaksel8783
@beckaksel8783 2 жыл бұрын
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 2 жыл бұрын
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! 😀
@benedekborbely9803
@benedekborbely9803 Жыл бұрын
Could we spare the "if-else" and make it branchless with modulo?
@relytheone853
@relytheone853 11 ай бұрын
How can I work for a company by learning from your videos?
@carlosrivadulla8903
@carlosrivadulla8903 2 жыл бұрын
pls can u conver the now built-in "tombllib" module? looks far prettier, simpler and more readable format than csv or json.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
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! 😀
@KadirMedia
@KadirMedia 2 жыл бұрын
Very nice tutorials, channel and a charming teacher . I recommend subscribing
@Alikhan-ee7bs
@Alikhan-ee7bs 2 жыл бұрын
I enjoy it when I apply cryptography in real life for example internet of things IoTs security cybersecurity and block chain etc.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
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 2 жыл бұрын
@@PythonSimplified i am using Linux for cryptography
@martinlutherkingjr.5582
@martinlutherkingjr.5582 10 ай бұрын
The wayscript link to the code no longer works. Is the code available somewhere else?
@firiasu
@firiasu 7 ай бұрын
I've been watching you for a few seconds and already fell in love ❤❤❤
@manuelr7121
@manuelr7121 2 жыл бұрын
i found another youtuber that you would make a perfect couple with !!
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Too late, Manuel! I'm already engaged to the man of my dreams! 🤩🤩🤩 (he's far from being a KZbinr hahaha)
@raivisrasnacs1088
@raivisrasnacs1088 2 жыл бұрын
I prefer pytest due to its non-oop nature. It's much easier to understand without prior oop knowledge.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
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)
@techwithdavid
@techwithdavid 2 жыл бұрын
Yet another great video👍
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Yeeeey! Thank you so much David, glad you liked it! 😊😊😊
@ojaimark
@ojaimark Жыл бұрын
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.
@diwakar_tsn
@diwakar_tsn 2 жыл бұрын
As always best video 😉❤️
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Glad you liked it! (despite not having any JavaScript involved hahaha) 😀😀😀
@sarc007
@sarc007 Жыл бұрын
Wonderful!!!
@elcanbayramli4444
@elcanbayramli4444 2 жыл бұрын
Hi, Where to get that live bachkgrounds?
@PythonSimplified
@PythonSimplified 2 жыл бұрын
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 😀
@hiutale
@hiutale 2 жыл бұрын
Amazing! Thank you~~~ ✨
@MrPioneer7
@MrPioneer7 2 жыл бұрын
Thanks a lot 👍
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Absolutely! enjoy! 😊
@jeuxmathinfo9578
@jeuxmathinfo9578 2 жыл бұрын
Very useful !!! Thank you so much !!! 🙂
@elvendragonhammer5433
@elvendragonhammer5433 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@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! 🤖
@soukron
@soukron 2 жыл бұрын
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.
@blankbox3403
@blankbox3403 2 жыл бұрын
Hello 👋👋👋 Please make a video on how to connect kivy with emulator to check how our apps look on mobile device
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you for your request, Morgan Freeman! hahaha I'll get back to covering Kivy soon, will definitely keep the emulator in mind! 😉
@yolow8126
@yolow8126 2 жыл бұрын
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 2 жыл бұрын
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) 😀
@gfoork324
@gfoork324 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@PythonSimplified thank you 💗
@juliuswanyama
@juliuswanyama 2 жыл бұрын
Excellent ❤
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you Julius! 😀
@abhijitkalita6931
@abhijitkalita6931 2 жыл бұрын
Great 👍👍
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you Abhijit! 😀
@super7ace
@super7ace Жыл бұрын
Beauty with brains ;)
@Mralex22801
@Mralex22801 2 жыл бұрын
Amazing 🤩
@TechNetworkz
@TechNetworkz Жыл бұрын
She is so awesome
@triggy60
@triggy60 Жыл бұрын
why my first law return ok ?
@krishagrawal6753
@krishagrawal6753 2 жыл бұрын
chr(ord(char) + 1) would be much better ig
@PythonSimplified
@PythonSimplified 2 жыл бұрын
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 2 жыл бұрын
@@PythonSimplified lol yea...
@solotron7390
@solotron7390 2 жыл бұрын
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 2 жыл бұрын
This is fantastic! Though 'z' becomes '{' (not 'a') and 'Z' becomes '[' (not 'A'), everything else works. Fantastically succinct idea. :)
@undeadpresident
@undeadpresident Жыл бұрын
I landed a segfault! woohoo!
@cezartorescu
@cezartorescu 7 ай бұрын
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.
@beluv
@beluv Жыл бұрын
Flashbang warning at 4:14
@agentm10
@agentm10 Жыл бұрын
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!
@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! 😉
@nargileh1
@nargileh1 4 ай бұрын
TDD is more than unit testing
@Super1234casper
@Super1234casper 2 жыл бұрын
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 2 жыл бұрын
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: ⭐ kzbin.info/www/bejne/haXVZ3WNYtp-fNU 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 😁
@osacaos
@osacaos Жыл бұрын
when a beautiful women tech you something it becomes v easy to understand thank you please mor videos
@lonely9183
@lonely9183 2 жыл бұрын
You are so pretty
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you dear! 😊
@clementfauchere3528
@clementfauchere3528 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@PythonSimplified I thought the example was sufficient, but a little too trivial which led you down a few misleading paths :)
@deeplazydev
@deeplazydev Жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
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!
@3dprofessor520
@3dprofessor520 Жыл бұрын
Im sick and tired of windows.
@1over137
@1over137 2 жыл бұрын
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 2 жыл бұрын
Checkout the pinned comment Paul, we've already discussed it with Jacob 😀
@3dprofessor520
@3dprofessor520 Жыл бұрын
Boycot windows. Its all BS.
@Æfsænti
@Æfsænti 2 жыл бұрын
красотка)
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Спасибо большое! 😊
@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).
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 414 М.
Dictionary Comprehension - Create Complex Data Structures Step by Step
21:58
Молодой боец приземлил легенду!
01:02
МИНУС БАЛЛ
Рет қаралды 1,8 МЛН
Real Man relocate to Remote Controlled Car 👨🏻➡️🚙🕹️ #builderc
00:24
Amazing remote control#devil  #lilith #funny #shorts
00:30
Devil Lilith
Рет қаралды 16 МЛН
Disrespect or Respect 💔❤️
00:27
Thiago Productions
Рет қаралды 42 МЛН
🌐HTML5 Course: Structural & Semantic Text Elements Part 2
24:43
Nomad Programming
Рет қаралды 49
Python Tutorial: Unit Testing Your Code with the unittest Module
39:13
Corey Schafer
Рет қаралды 1,3 МЛН
Pytest Tutorial - How to Test Python Code
1:28:39
freeCodeCamp.org
Рет қаралды 217 М.
Python dataclasses will save you HOURS, also featuring attrs
8:50
List Comprehension - BEST Python feature !!! Fast and Efficient
14:51
Python Simplified
Рет қаралды 197 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
Это самый популярный гаджет в мире
0:20
Q Mobile SL 100 Best Mobile Phone
0:44
Gaming world
Рет қаралды 940 М.
Лазерная замена стекла iPhone 14 plus
1:00
Mosdisplay
Рет қаралды 3,4 МЛН