Python Challenges: Nth power

Transcript

English (Auto-generated)

Hello everybody. I hope everybody is doing well. So in this code cast we're going to be doing a problem called End Power. Okay. I gotta give some credit to code wars because we got awesome problems anyway. So basically it's kind of a tedious problem to explain. But you're given an array with positive numbers and the non negative number. And okay, you should find the end power of the element in the array with the index. And okay, if n is outside of their rate then return negative one. Okay, so it still seems very decently simple. So let's go ahead and do this. Okay, so really quick. I'm just gonna clear my terminal forgot to do that. So your true. Okay. So now what we're gonna do here is instead of past, the first thing that we obviously want to do is check if the end is outside of the rib acres wide. And do the other thing if and so what we're gonna do is if and no no, okay, its length of the array is greater than N. Then we're just gonna run this. Okay. Okay. So now what we're gonna do is we're gonna store it in unbearable calls and power and that empower equals. Okay. The arrays the index of array like so and then to actually do a double patient time and then to the power of N. And then we just return and power very very simple. And if it's outside of the way basically if this doesn't work, we're just gonna return negative one. Like so this is the first time I did this I acted to this four loop and it was like this whole crazy scenario but I decided to just show you guys how to do. It's like the way is greater than end and power through that and it's a lot cleaner and simpler. Instead of showing you guys basically a bad version then show you guys a good person. I'm just showing you guys a good version. So yeah that's basically how you do that this problem. Um There's a lot of ways that you can go about this. Well not that many honestly but there are different ways that you can go about this. So I would like to see the dress solution stuff. I think that would be cool. Um And yeah if you have any tips hug so it's better to just let me know and yeah thank you for stopping by. This is a very easy problem but I consider it a very tv is fun if you don't read the instructions currently you're not gonna be able to do it correctly or efficiently. So yeah this is how you do that and thank you so much for joining. See you later.
78 Views 0 Likes 0 Comments

In this codecast we are given an array and n (which is a non-negative number) we have to find the result of that array's nth index to the power of n. T...

Comment
Leave a comment (supports markdown format)