best python institute in Delhi
Pyhton Beigneer Guide
Welcome Back Everyone in This Lecture. We're Going to Go over the Solutions for the Practice Problems That Were under Level 1. Let's Open up That You Brought a Notebook and Continue Ok.
The First Problem Was This Old Macdonald Problem Where We Wanted You to Write a Function That Capitalises the First Four Letters of a Name, and There Are Two Different Ways We're Going to Show You How to Do This. One Is If the Capitalised Method and Then the Other Is the above Method.digital marketing company
We Haven't Shown You the Capitalised Method yet Except We Added a Note Here That Basically What Capitalised Does Is It Grabs an Entire String in Other Cases the First Letter in That String. best institute for machine learning So Let's Do First with the Upper and Then We'll Show You How to Do with Capitalise. First, We Want to Grab the First Letter. So I'm Going to Say the First Letter Is Equal to Name Zero. python and machinree And Then I Want to Grab the Characters in Between. So We'll Call These In-between Characters. best python course
And Those Are Going to Go from Name Index One up to Let's Say Index Three and Then We Want to Grab the Fourth Letter. So Say the Fourth Letter Names Index Three. And Then Finally the Rest Is Going to Be Named from Index Four Onwards.seo services So Let's See If This Works, We're Going to Return the First Letter with In-between with the Fourth Letter plus Rest.
So Let's See If We Get the Same Result There. Ok. So Good We Get Back. Mcdonald Now Want to Do Is Uppercase the First Letter, and Then I Want to Uppercase the Fourth Letter, and Then We Run This. We Get Back. Mcdonald so This Is How You Could Do This with Uppercase Using Just Indexing and Slicing You Separated Uppercase What You Need and Then Concatenate It Back Together Again. But You Can Also Do This with the Capitalised Method, and the Capitalised Method Is Going to like to Do Fewer Slices. So What We Could Do Is Separated into Two Halves.
so Say the First Half of the Name Is Going to Be from Name from the Beginning to Index 3. So It's Going to Be the Mack Part and the Rest of It. That Second Half. A
nd It's Not Really an Even Half I Should Say Probably Second Part Is Going to Be from Three All the Way to the End and Then All We Could Do Is the Following a Can Say First Half and Instead of Calling Upper I'm Going to Call Capitalize and Then I Will Concatenate That with the Second Half and Capitalize That in Our We Run This. We Get Back the Same Results. Say You Could Use the Capitalised Method Instead of the above Method.
you End up Doing as You Create a String. You're Going to Have a String of Toothaches and Then Offer the String You Say Join. And Then You Pass My List. And What This Does Is It Takes the String You Have Here, and It's Going to Use It to Concatenate as a Fill-in Between. Every Item in the List.
If I Just Have a Space Here It Puts a Space Between a B and C If I Have Maybe a Bunch of O's Then It's Going to Put a Bunch of Rows in Between a B and C
So a Lot of times When You Want to Join Things Together Such as Words on a List You Can Either Have It as an Empty String Just a Blank String to Single Quotes Right next to Each Other Abc or You Can Have Space Here and It Joins to Get the Other a Space Bc. So to Get This Back as a String Sentence What It Could Do Is Fine. Instead of Just Saying Reverse Wordlist I Could Say Single Quote Space Single Quote Join the Reverse Word List. And Now When I Run This, I Get Back the Original String Itself. Home Am I. And Then Ready,
Are We? So That's the Introduction to the Join Method. In Case You Haven't Seen It Before. Finally, We're Going to Discuss the Almost There, and That Was given an Integer N Return True and Is Within 1 10 of Either 100 or 200.best digital marketing institute in delhi
So the Way We Can Do That Is by Taking Note of Abs. So Abs Return the Absolute Value of a Number. So We're Going to Return and Check for the Following. We Want to Check If 100 minus and the Absolute Value of That Is Less than or Equal to 10. So We Want to Check That, but We Also Want to Check Another Situation.
you can also watch here https://www.youtube.com/watch?v=LzHc7VC5bfA
So We're Going to Raptus Princes to Kind of State That's One Thing We're Checking or Want to Check If the Absolute Value Between 200 and an Is Less than or Equal to 10. And Then Finally We Can Return This. So We're Just Checking Hey Is 100 minus Number the Absolute Value of That. The Difference Between That Number and 100 Is That Less Equal to 10. Or Is the Difference Between That Number and 200 Lessner Equal to 10. And We Run This. We Get Back the Correct Results. So This Is False. This Was True,
and Then This One Is Also True. Ok. That's the Basics. Level 1 Introduces a Couple of Things Here Mainly the Common Method and the Absolute Value Function in the Very next Lecture. We're Going to Go over the Level Two Problems We'll See.