Hey, what's up?
John Sonmez here from simpleprogrammer.com.
I got a
question about fasting and about a book that I did a review on.
There's this book on Obesity Code.
You can check it out here and it's a really good book, actually.
It really changed some of my mindset on some of the things as far as fitness.
I've actually changed my diet quite a bit.
In fact, I'm just coming off of a three-day fast.
It's Tuesday now.
I just broke the fast yesterday, but I stopped eating Friday night and I didn't eat Saturday
or Sunday, or Monday until Monday evening when I broke the fast.
It's a good three-day fast.
I'll tell you.
You'll learn a lot about yourself if you don't eat for three days.
You'll learn a little bit about who you really are.
I've done this enough times that I've sort of been able to go there and learn, gain some
insight from that.
It's definitely something I encourage, but, you know, obviously, check with your doctor.
I'm not a doctor so if you don't eat for three days and somehow you die, it's not my fault.
You're the idiot who didn't eat for three days.
Okay?
I got this question from Kevin and Kevin says, "Hey, John.
I've read the book you recommended, Obesity Code.
I imagine you did three days of fasting based on that book."
There you go, my brother.
All right.
He says, "Have you seen any benefits?
I do know that you fast 24-hour period."
My normal regular scheduled fasting is everyday.
I basically don't eat for 22 hours or 23 hours.
I eat one meal a day.
I fast all day long.
I haven't eaten today.
I won't eat until like 5:00 or 6:00 and that will be the one meal I'll eat.
That's my protocol.
He says additional info: "Another is how you deal with hunger during fasting.
I actually managed to subdue my hunger, but when I see delicious food in front of me,
I couldn't resist.
Thankfully or not thankfully, my wife loves to cook delicious food and it's so hard to
resist."
A couple of things here, Kevin.
Some benefits.
There are some definite scientific benefits.
I'm not going to go like in-depth into science here in this video since I don't have any
research in front of me, and I'd just be coding up fake statistics that I don't have in
front of me.
I will tell you this.
HEH levels when you fast have been proven to rise dramatically as much as up to a thousand
percent, and it sort of peaks around 48-72 hours.
A three-day fast like that is going to give you a very high HEH level, which I can feel.
When I went to the gym yesterday and I hit the—I hit PRs on a lot of lifts with no
food for three days.
A lot of people will say, "Well, that doesn't make any sense like you're going to be"—They
always say this.
They say, "Well, if I did that, I would lose a bunch of muscle and I'd faint."
I'm not saying that you won't faint.
Maybe you would.
It depends on your blood sugar, but for most—but think about this from a biological standpoint.
Let's say you're a caveman and let's say that you haven't eaten for four, five days because
the only way that you get food is you fucking kill something and you eat it.
What do you think would be a biological advantage?
You think that you should be at your weakest at that point like you're like, "Oh, I can't
hardly hold this spear.
I haven't eaten for four days," or do you think you're going to be jacked?
Do you think that your body is going to be pumping you full of adrenaline like you better
kill something or you're going to die and you're going to have superhuman strength?
Which do you think makes more sense?
Okay?
Think about that.
That's just something to think about.
I know we're on the same—I know I'm preaching to the choir because you read the book and,
obviously, you like the book, but for those of you that are doubting and wondering about
this, that's my explanation like come up with a better sound reason why.
You know, come up with a reason why you should be like ready to pass out and weak after not
eating and I'll entertain it, but it doesn't make any sense to me from a biological standpoint.
Anyway, that's one benefit of it that I find.
The other one is just the mental clarity.
Like I said, you learn a lot about yourself by not eating for three days.
It's hard.
It's difficult.
It's not an easy thing to do, but you learn about what you can endure that being hungry
is not that bad.
Also, I do like 10-mile runs when I'm fasting as well.
Just like what you're capable of.
It's pretty awesome when you're like you haven't eaten for three days and you ran 10 miles
and lifted a bunch of weights, and you're like, "Wow there's a lot of stuff in life
that I thought was hard.
Now, it seems easy because if I can do that, what can't I do?"
I think that's something and, again, I've done videos on this before where I've talked
about like that where you're at worst is your actual best.
What I mean by that is like when things are hard and how you're acting in that time, that's
what you actually are.
That's the real you coming out.
If you put yourself through hell, if you put yourself through fasting for three days, that
personality that you have then, that's the real you and that's where you can actually
work on that real personality because if you improve yourself, if you can hold back your
temper, if you can control your emotions, if you can have emotional mastery at that
point, when you're not under that kind of pressure, it will be much easier.
That's where you really get to do some really deep self-development.
At least that's what I find.
Just from a health benefit, I mean like I said, you read Obesity Code.
You know that the most efficient way to burn fat is to fast, obviously.
When you do that, you also prime yourself to build muscle with the HEH increase.
From a health standpoint, I think that it's highly beneficial for what I'm trying to achieve
physique wise.
I've had great benefits and great results from it, and then also from a medical standpoint
there's been a lot of studies showing that fasting is helpful to your health, everything
from preventing cancer to program cell death which is—I'm losing the name for it now.
Anyway, those things can help to renew the body.
Now, as far as dealing with hunger, I'll answer that real quick.
This is one of those things that like—I mean it subsides, like hunger comes and goes.
You're not like constantly hungry.
It's going to come and go, so the best thing to do is just to distract yourself and go
do something else or just recognize it.
I mean being self-aware is really powerful.
Anytime you're trying to master any kind of emotion or feeling being self-aware and just
saying, "Okay, I feel really hungry right now."
I know it sounds really stupid, but if you acknowledge and you say—because then you
acknowledge the difference between the urge to eat and the feeling of hunger.
Do you see what I'm saying?
As creatures, biological creatures, we tend to like—we go with what we desire.
We don't make the connection always between the emotion and the feeling, and then the
action.
When you separate those two and you say, "I'm hungry.
I'm feeling hungry," and you feel what that feels like, you're like, "Oh, that doesn't
mean I have to eat.
It just means that I would want to eat," but it doesn't mean—I know it sounds a little
bit silly, but try it.
It will help you.
Then as far as delicious food, you just got to develop the—again, I would say that the
biggest with that is that I always tell myself that FoMO, fear of missing out.
FoMO.
I did a video on FoMO.
I think I even talked about food and stuff like that because—there are some delicious
food in front of you.
You can eat delicious food anytime you want.
I always tell myself, "John, you're a grown ass man.
You can go to the store and you can buy a whole fucking cheesecake if you want.
You can eat the whole thing if you want.
Anytime you want."
This is like—you can do this.
This is amazing, right?
Why do you feel like just because someone brought cupcakes into work that you've got
to eat the cupcakes or some cooked delicious food?
You can go to a nice restaurant and eat delicious food.
You see what I'm saying?
If you're trying to fast, if you're trying to not eat, then just don't do it.
Don't like indulge it because you're afraid of missing out.
Anytime you make choices in life like that where you're afraid of missing, that FoMO,
you make bad choices.
I mean there are definitely occasions where it's once in a lifetime opportunity, but most
of the time someone cooking a good meal or someone bringing cupcakes into work is not
a once in a lifetime opportunity.
I mean let's be honest here and how much are you really selling missing out anyway.
Some hedonistic pleasure for like a few minutes of enjoying some food.
Big fucking deal.
What are your bigger goals in life?
That's what I remind myself when I'm hungry.
Okay, I'm hungry right now so I'm reminding myself that.
All right.
That's all I got for you today.
Thanks for question.
Check out the book if you haven't, The Obesity Code.
Check my review on it.
I think it's a really good book.
I think everyone should read it, and that's all I got.
All right.
If you like this video, if you haven't subscribed already, make sure you click that Subscribe
button below.
Click the bell so you don't miss any videos.
I'll talk to you next time.
Take care.
For more infomation >> Fasting For Multiple Days: GOOD OR BAD? - Duration: 9:13.-------------------------------------------
3 Simple Tips For Mixing Background Vocals Like A Pro - BehindTheSpeakers.com - Duration: 7:38.
Wondering how you can mix background vocals that sound like the pros?
Keep watching to find out.
Hey, this is Jason Moss from BehindTheSpeakers.com, and today you're gonna learn three simple
tips for mixing background vocals that sound clear, balanced, and radio-ready.
Now, before we dive in, I also put together a free vocal mixing cheatsheet that's packed
with tips and tricks for taking your vocals to the next level.
So if you wanna download this, it's completely free.
You can click the link in the description below or up there in the video to get instant
access right now.
My first tip is to process background vocals independently.
Now, most of the time when we're talking about background vocals, we're not just talking
about one track.
We're talking about eight tracks or 16 tracks, where there are multiple versions of the same
part, or there are multiple parts that make up a background vocal arrangement.
Now, a lot of the time, people will group all of these tracks together and they'll process
them on the group.
Now the problem with this approach is, let's take compression, for example.
If you put a compressor on a group of background vocals, the compressor can't control the level
of individual background vocal tracks within that group.
All it can do is turn down the level of the entire background vocal stack.
And so what ends up happening is, while you might control the level of the background
vocals as a whole, you're not evening out the differences in dynamics and volume between
those individual background vocals.
So instead of processing things on the group or on the bus, it's usually a better approach
to apply processing to each individual track in your background vocal group.
So usually that's gonna give you better results.
You can apply some processing on the group of vocals, maybe some subtle EQ or even some
compression.
But for the most part, I try to do most of the heavy lifting on the individual background
vocal tracks within that group.
The second tip is you wanna tighten up the timing.
Now, timing between background vocals is incredibly important.
And whenever you get one performance that's been recorded multiple times, it's very natural
to have subtle variations in those performances.
So, in one performance, the vocalist might have sang a note a little bit later than another
performance, so you have all these subtle different variations, right?
But over the course of a group of background vocals, it just creates this kind of messy,
sloppy sound where things are kind of starting and ending in different places, and it just
sounds kind of amateur.
So what I like to do is go through the individual tracks and actually tighten up the timing
and make sure that everything's kinda consistent.
Things are starting and ending in the same spot.
There's no kind of weird performance where something just kinda pops out and it comes
way earlier than the rest of them.
And I usually like to use the lead vocal as the guide.
If you match the timing of the background vocals to the lead vocal, that's always gonna
lead you in the right direction.
Now, there's a tool called Vocalign that you can download.
It's a plugin that will allow you to basically do this automatically.
It's not always 100% effective, but this is a great tool when you have tons of background
vocals if you just wanna line things up really quickly.
But I wanna jump into my DAW and show you basically how I approach this manually.
So if you don't have this plugin, don't worry.
I'm gonna show you right now how I do this and clean up the timing on the background
vocals in my mixes.
Okay, so I have a track here called "It Starts Today" by artist Leah Capelle.
I wanna take a listen to the lead vocal and the chorus, along with the background vocals
in solo.
So something just to note here, Leah is an amazing singer and her background vocals always
come in perfect.
I never have to do anything to them.
So I actually had to move things around a little bit just to create this demo.
So don't be deceived—Leah's an amazing singer.
♪Oh I won't tell you to put your hands up ♪
♪ 'Cause we all know we're gonna get stuck on the wire ♪
♪ Our feet to the fire ♪
♪ So tell 'em right now we're gonna be free ♪
So the timing isn't terrible by any means, but I feel like things can be a little bit
tighter.
The background vocals don't quite mesh with the lead vocal.
And when you have tracks like these where there are a lot of words going by very quickly,
it's pretty common to have this, where the timing is just a little bit off.
So if we scroll down here, you can see there are four background vocal tracks.
So what I'm gonna do is drag this first background vocal track up so it's right below the lead
vocal track.
I'm gonna zoom in a little bit and just make this a little bit bigger.
And using the lead vocal as a guide, I'm basically gonna adjust the timing of the background
vocal tracks so that it matches the lead vocal a little bit more closely.
Now, depending on what you're working in, what DAW you're working in, there are different
ways to do this.
In Pro Tools, there's something called elastic audio, and the way that you turn it on is
over here.
So I'm just gonna set this to monophonic, 'cause there's only one note at once in this
vocal track.
And then I'm gonna change the view mode on this track to warp.
Now, if you're in another DAW, obviously these steps are gonna be different, but you wanna
just look in your manual for elastic audio, flex time, or something like that that allows
you to adjust the timing of individual tracks.
So I'm gonna zoom in here, and now you can see we have these warp points.
And I can go through and basically adjust the timing of this background vocal track
to match the lead vocal a little bit more closely.
So I'm gonna just do this visually.
I'm not really listening to things right now.
I'll probably listen to it later and make sure that things are lining up and that there's
no kind of weird glitches or anything like that.
Now after I'm done with this background vocal track, I'll go through the rest of the background
vocals and do the same thing.
If you take the time to do this, I know it's kind of a pain and, you know, it's not the
most fun part of the music-making process, but this is the stuff that really is gonna
make a difference when it comes to the sound of background vocals.
And it's just gonna make things sound a lot tighter, cleaner, and a lot more radio-ready.
It's just gonna sound like the stuff you hear on the radio.
The third tip is to remove the breaths on the background vocals.
Now, this might sound a little bit weird; I know a lot of people like to leave the breaths
in.
But I've found that the breaths can often be sources of inconsistencies between the
tracks and the background vocal group.
So often times, one track, the vocalist will have taken a breath in earlier, and in another
one it's kind of late.
And so you get this kind of mish-mosh of different breaths that occur at different times.
And the trick here is you can often get rid of the background vocal breaths completely
and you're not gonna miss them.
Now, I always leave breaths in on the lead vocal, and I'll automate them if they're too
loud so they don't get distracting.
But because you have those breaths on the lead, you can often get away with just taking
them completely out of the picture on the background vocals and you don't miss them.
Because really, they're only a secondary element in the mix.
So by getting rid of those breaths, it's just gonna contribute to a cleaner, tighter background
vocal sound.
You're not gonna have breaths that are all over the place, that are pulling you away
from whatever the primary focus of the track is.
I hope you enjoyed these three tips for mixing background vocals.
And if you want to dive deeper, I put together a free vocal mixing cheatsheet that's packed
with tips and tricks that I didn't have time to cover here.
So if you wanna download this, you can click the link in the description below or in the
video and you'll get free instant access.
Thanks so much for watching.
And if you want more mixing tips like these, you can check out my website, BehindTheSpeakers.com.
Take care.
-------------------------------------------
How To Draw Easy and Simple Village Scenery With Pencil Step by Step | Scenery Drawing - Duration: 12:58.
I Used : Staedtler { Mars Lumograph Black Pencil 4B }
Thanks for watching
-------------------------------------------
Make grunge simples com glitter | Simple glittery grunge makeup - Duration: 6:45.
Concealer by Vult color R-102
Face powder by Marchetti color Natural 01
Face powder by Mary Kay color Beige 2
Eyebrow pen by Vult color 02
Black eyeliner pencil
Black eyeshadow by Bless Cosmetics
Highlighter pencil by Vult
HD foundation by Vult color B-05
Translucent powder by Mary Kay
Face powder by Mary Kay color Beige 2
Eyeshadow primer (by O Boticário) + Glitter 01 by Vult
Clean brush
Blush by Mary Kay color Shy Blush
Homemade highlighter (link in the description)
Eyelash mascara by Natura
Matte liquid lipstick By Dailus - color Jetés
And u're done! :)
Thank u so much for watching
Don't forget to subscribe!
Luv y'all! Bye :3
-------------------------------------------
Simple Winter / Christmas Nail Art | Streitthema: KVO - Infobox | Carat Nails - Duration: 23:31.
-------------------------------------------
How to Draw a Simple 3D Effect: Woman With Umbrella - Duration: 4:12.
Hello my friends and welcome to another Tuesday of tutorial!
I am Leonardo Pereznieto and today we will do a simple drawing
of a woman with an umbrella, in 3D.
We begin by sketching the head with the hair, then the shoulders
and we come down through the body… and the legs.
We do the arms, her dress and an umbrella.
I want to do a 3D effect in a very simple way.
Let´s see how it turns out!
We shape the legs a little bit better
and she will be standing in water.
She will be coming out of this water,
but the liquid will be only in a small space.
Similar to a photograph
which will be bending up on the sides, just a little.
I will actually correct this to bend it a little bit more.
Like so.
Good!
And now we can start shading.
I´m using a Tutto3 mechanical pencil, which has leads in three
different sizes and three different hardnesses.
The list of materials is in the description below the video.
Here the trick to make this drawing look tridimensional,
is that we are using two different perspectives.
One is the one of the photograph which is like laying down on a surface.
Now, imagine that that piece of paper that I drew at the bottom was a photo,
and that this photo have printed on it the image of the girl with
the umbrella.
It will be in the same perspective as the piece of paper laying down
which is totally different than how we are looking at this girl.
That is, standing up and we are looking at her practically straight
from behind.
As you see, these are two totally different perspectives, and that
is why it looks like she is coming out of the photo.
At least that´s the idea [laughter].
Let´s shade her legs, and… she is wearing a dark coat,
as you see.
Which I make it a little darker, especially I´ll give it some shape
and some volume by adding some shadows.
I am experimenting on how to do simple but effective
3D effects.
Next week I will try another technique
which I just thought of, and which I will test for the first time.
I actually have a whole video playlist, that is a series of videos,
with 3D and special effect experiments
which I will place at the end of this video, in case you are
interested you can just click on it.
And now let´s draw the shade to the paper.
Like so.
The corners will be lifting a little bit.
Although the paper is bending up, the shadow I draw it flat
so as to create the illusion that is lifting.
Ok, that looks better!
And I clean up the drawing a little bit.
As you have probably noticed, I have been using a kneaded
eraser.
Which is my favorite because it is very clean
and you can shape it exactly as you need it.
Very good!
¡Excelente!
It´s ready!
If you enjoyed it please give it a LIKE! share it
to your friends and subscribe to Fine Art-Tips.
And I will see you on Tuesday ;)
Subtitled by Grethel Trejo
-------------------------------------------
Newt Gingrich Makes Shocking Reveal, He Said 3 Simple Words That Will End Trump-Russia Investigation - Duration: 3:01.
The Silence Is Broken! Newt Gingrich Makes Shocking Reveal, He Just Said 3 Simple Words
That Will End Trump-Russia Investigation For Good
Newt Gingrich has one justifiable reason motivation behind why you shouldn�t put stock in the
free Russia investigation. Keep in mind a couple of things � the investigation�s
head, Robert Mueller, should be non-partisan. What�s more, in fact, when he was first
contracted, everybody applauded him for being quite recently that.
So it�s a little odd that his activities are currently indicating support to Democrats.
Which might be the reason Gingrich is stating that his investigation is rigged.
Via MSN:
Former House Speaker Newt Gingrich, a key ally to President Trump, [said this morning]
that the ongoing investigation into the Russian interdling of the election, led by Special
Adviser Robert Mueller, is a �rigged game� for its lack of pro-Trump attorneys On the
case.
While Gingrich said he would not recommend that Mr. Trump should fire Mueller, he questioned
the investigation�s impartiality since Mueller has so far hired four Democratic attorneys.�He
apparently could not find a single pro-Trump attorney to hire, and I just think that�s
a rigged game, and I think it�s a mistake to pretend this is going to be some neutral
investigation,� Gingrich said.
Gingrich is right. Mueller has the ability to enlist his own investigative group. Furthermore,
the main individuals he�s employing all originate from the Democrats. Newt knows a
rodent when he notices one.
The most exceedingly awful piece of everything is that it�s a change of heart � Gingrich
at first had a favorable opinion of Mueller. As did most men and ladies in Congress.It�s
simply subsequent to watching Mueller�s activities that he is starting to have questions.
Asked if he thought the attorneys were �anti-Trump�, Gingrich responded, �Well all four gave
money to the Democrats,� and later laughed off a suggestion that they were the best attorneys
Mueller could find.
�You�re suggesting that in the whole country there are no republican attorneys that Mueller
could have hired,� he added, �I do not give the benefit of the doubt to someone who
could only hire Democrats but claims we should trust him . �
Libs in Congress have your run of the mill reaction � �Gingrich is just trying to
sow distrust in the investigation, blah, blah, blah.� But Gingrich has a straightforward
approach to gauge transparency, and he explained it:
�Let�s just have transparency. Could we have as many pro-Trump lawyers as we have
anti-Trump lawyers? �Something discloses to me that Mueller wouldn�t accept Gingrich�s
recommendation.
What do you think about this? Do not hesitate and write your thoughts in the comment section
below.
-------------------------------------------
Newt Gingrich Makes Shocking Reveal, He Said 3 Simple Words That Will End Trump-Russia Investigation - Duration: 3:00.
The Silence Is Broken! Newt Gingrich Makes Shocking
Reveal, He Just Said 3 Simple Words That Will End Trump-Russia Investigation For Good
Newt Gingrich has one justifiable reason motivation behind why you shouldn�t put stock in the
free Russia investigation. Keep in mind a couple of things � the investigation�s
head, Robert Mueller, should be non-partisan. What�s more, in fact, when he was first
contracted, everybody applauded him for being quite recently that.
So it�s a little odd that his activities are currently indicating support to Democrats.
Which might be the reason Gingrich is stating that his investigation is rigged.
Via MSN:
Former House Speaker Newt Gingrich, a key ally to President Trump, [said this morning]
that the ongoing investigation into the Russian interdling of the election, led by Special
Adviser Robert Mueller, is a �rigged game� for its lack of pro-Trump attorneys On the
case.
While Gingrich said he would not recommend that Mr. Trump should fire Mueller, he questioned
the investigation�s impartiality since Mueller has so far hired four Democratic attorneys.
�He apparently could not find a single pro-Trump attorney to hire, and I just think that�s
a rigged game, and I think it�s a mistake to pretend this is going to be some neutral
investigation,� Gingrich said.
Gingrich is right. Mueller has the ability to enlist his own investigative group. Furthermore,
the main individuals he�s employing all originate from the Democrats. Newt knows a
rodent when he notices one.
The most exceedingly awful piece of everything is that it�s a change of heart � Gingrich
at first had a favorable opinion of Mueller. As did most men and ladies in Congress.It�s
simply subsequent to watching Mueller�s activities that he is starting to have questions.
Asked if he thought the attorneys were �anti-Trump�, Gingrich responded, �Well all four gave
money to the Democrats,� and later laughed off a suggestion that they were the best attorneys
Mueller could find.
�You�re suggesting that in the whole country there are no republican attorneys that Mueller
could have hired,� he added, �I do not give the benefit of the doubt to someone who
could only hire Democrats but claims we should trust him . �
Libs in Congress have your run of the mill reaction � �Gingrich is just trying to
sow distrust in the investigation, blah, blah, blah.� But Gingrich has a straightforward
approach to gauge transparency, and he explained it:
�Let�s just have transparency. Could we have as many pro-Trump lawyers as we have
anti-Trump lawyers? �Something discloses to me that Mueller wouldn�t accept Gingrich�s
recommendation.
What do you think about this? Do not hesitate and write your thoughts in the comment section
below.
-------------------------------------------
Husqvarna 701 Vitpilen & Svartpilen concept | VITPILEN 701- Simple. Progressive. | Mich Motorcycle - Duration: 1:26.
-------------------------------------------
Simple Sambar Recipe | Easy Sambar | How to Make Sambar | South Indian Sambar Recipe | Sambar recipe - Duration: 1:23.
Add your choice of veggies
Toor dal can be cooked separately as well
-------------------------------------------
PHOTO – Lily-Rose Depp vêtue d'un simple mini.. - Duration: 2:11.
-------------------------------------------
Une astuce simple pour détoxifier votre corps et perdre du poids chaque jour - Duration: 3:11.
-------------------------------------------
Une astuce simple pour détoxifier votre corps et perdre du poids chaque jour - Duration: 2:41.
-------------------------------------------
High Profile PolyGeyser: Simple and Quick Daily Maintenance! Hungry catfish feeding Frenzy! - Duration: 2:06.
Hey!
I'm Paul Begue, AST systems designer.
Right now, we are at one of our production tanks at our R&D facility in New Orleans.This
is a 2200 gallon tank stocked at approximately .75 pounds per gallon with adult blue catfish.
Alright, so we are going to do a feed real quick.
You can see how active they are during the feed.
The filter operating on this system is a ten cubic foot high profile PolyGeyser.
This is an automatic self backwashing filter where the sludge drain is very simply done
after backwashes have occurred by turning one valve.
Okay?
So while these fish eat, we are going to go down and drain sludge.
Let's see what that looks like.
Down here we've got our unscreened bottom drain.
The pump is still running.
The filter is still backwashing as needed automatically by air driven pump.
I'm going to turn this valve, let's take a look at this bucket right here.
So we have some nice, thick brown sludge right here.
Now what I am going to do is, I am going to wait till that runs clear.
Once it runs clear, no more sludge production.
Normally, it's about two five gallon buckets before we have clear water running out.
Alright.
This is the only maintenance that I need to do on the system on a daily basis.
I just turned the valve.
I am finished with maintenance on this system for the day.
Stay tuned for more videos on the High Profile PolyGeyser.
Thanks so much for watching.
-------------------------------------------
Débarrassez-vous des pointes fourchues sans les couper avec cette astuce simple - France 365 - Duration: 4:40.
-------------------------------------------
06 Beginner's Guide to Python - Simple Functions - Duration: 13:55.
In this video I'm going to show you how to use functions in Python. Okay so let's
load up our atom editor with our project that we had from our last lesson. We're
going to create a new file here and let's call it functions.py okay so this
is our new blank functions file now a function in Python is just a way of
defining a block of code that you can repeat elsewhere in the... in your source
code. The difference between a function and a while loop or something like that
is that a function you can pass in various variables to customize the
variables in the code that you execute so I'm going to demonstrate how
you do this and then you'll understand how it works and how they can be useful in
your code. Ok so let's pretend we're writing a piece of code for a store and
let's stick with the same theme that we've had in the previous two videos
we're going to be selling apples in our store and let's say we want to write a
simple script that greets the customer when they come in so we want to greet
them by their name and we want to tell them how many apples we have in stock. Ok
so let's start by just writing these lines out individually so let's print
"Hello, Mark" and under that print "We have 6 apples in stock". Ok so I'm gonna save
that file and let's copy and paste these two lines and paste them two more so we
have this 3 kind of blocks a code here and let's change the name so let's
say we have Brooke and then we have Greg coming to the store. Alright so save the
file and then load up the terminal or command prompt window and let's run our
function script by typing python functions.py. Okay so you can see that
it outputs on the screen the name of each person and how many apples we
have in stock. Alright so you can see that this code is a bit repetitive we've
repeated the same thing three times we literally had to copy and paste and all
we've done is changed the text in here and there's a lot of repeating text that
we've entered more times than we need to. So for example "hello" here this is the
same for all of them. And "we have" and "apples in stock"... well this actual string
is the same for all of them but let's pretend that this may change so we're
basically...You can see that it's repeating the code here. We're also repeating the print
functions and there's a lot of repetitiveness going on. Good source code
has limited repetitiveness. There's a concept called DRY which is do not
repeat yourself and that means don't repeat unnecessary blocks of code in
your application because then if we ever wanted to change this text we would have
to change it in all of these three places as opposed to just changing it in
one. So I'm going to show you how you can use functions to reduce code
duplication. Alright so before we actually reduce the code duplication I'm
just going to show you how to make a simple function in Python. Alright so the
way you define a function in Python is you use the DEF - it's short for define and
then the name of the function that you want to define. So let's create a
function called greet mark so I'm going to define def and I'm going to create a
function called greet_mark and each function that you define needs to
end in two brackets I'll explain why a bit later in this video. Alright so you
write def, the name of the function, open and close brackets and then a colon. If you
hit enter after the codon you can see that Atom automatically indents this
here because as with the while loops that we learnt in the previous lesson
the function code is grouped by the indentation so any code we want to
include in this function needs to be indented by one tab underneath this
function. Okay so that's our first function let's create one for each of
these blocks so I'm gonna copy and paste this here, copy and paste this here
then I change this to Brooke and I'm going to change this to Greg and then I'm
gonna indent these two here, save that. The best practice is to use two spaces in
between these functions when you're doing it in a single Python file like
this. So now we've defined our function if we go to our command
prompt and we run the code you actually see that it doesn't output anything now
and that's because defining the function just isn't enough you actually need to
call the function after you defined it. So underneath these functions we're
going to call the function so make sure that we're indented back to the base
level of the file and the way you call the function is you simply provide the
function name and the brackets without the def because
we've already defined it. We just want to call it now so if I write greet
mark and then again I'm gonna copy and paste that I'm gonna put greet Brooke
greet Greg and then save the file and if you load up command prompt push up and
do Python functions you can see their outputs exactly the same as before
and it may seem backwards because we've actually created more lines of code
instead of reducing the lines of code which was the goal but I'm
just demonstrating how you define functions now I'm going to demonstrate
how you can use functions to save...reduce...or sorry to reduce the lines of code in
the application. Okay so one of the things that you can do with functions is
you can pass in arguments to the function, so you can define various
arguments that you can provide when you call the function and then the function
can use those arguments in the source code. Alright so if we delete these two
here because they're pretty much the same, and we can also delete the calls to
them here as well and let's rename our function instead of greet mark which is
very specific and doesn't help with... it doesn't help with reducing duplication
let's just call the function greet customer. And then in between the
brackets here we're going to define a variable and we're going to call or it's
actually an argument, we're gonna define an argument for our function and we're
going to call the argument name. Okay so if we call the argument name and then we
hit save and now when we call our function....actually before we do that
we're going to change this print here and instead of printing mark which we've
hard-coded here we're going to update this to include our variable. So print
hello and we'll leave the string there before the end of the print the last
bracket in the print use the plus symbol and this will concatenate our name
variable with this string. So what this is now doing is its greeting a customer
and it's allowing us to provide the name of the customer and it will include that
name in the code that it prints out. Okay so below this let's write again
greet_customer and then we need to provide the name of the customer we want
to greet. So you define the variables when you call the function, you define the
variables in the same order that you put them in the greet customer arguments and
since we only have one we can just type it here. We'll just put the
name mark and then we'll copy and paste this and we'll call it Brooke...and we'll call
it Greg. Save that. Now load up the command prompt
and let's run our file again and now you can see it outputs the same again except
this time we have a lot a lot less lines of code than we had before.
Okay so let's say we wanted to update this function and we want to actually be
able to change the number of apples that we have in stock because if Mark comes
into the store then after he's left the store there may be less apples in there
when Brooke comes in. Okay so you can actually define multiple arguments for a
function here and you do that just by comma separating the list of argument
names in the function argument bracket. So let's just call a new argument called
num_apples just short for number of apples and then similar to what we did
here where we added the value of this to our string I'm going to delete this and
then add the quotes here so we now have two strings and do +. And we actually need to
convert this number type into a string so that we can add it to our
string because you can't just add numbers into strings using the plus
symbols so we'll just type STR and then num_apples
so what this STR does is it converts this whatever variable this is into the
string type so it basically converts our number into a string so instead of it
being the number six it will just be a string saying six. Okay so now we need to
add this argument to the call when we call our function so let's add... let's
start with seven and then let's say there's six
and then let's say when Greg comes in there's two left. Save that and then go
back to our command prompt, hit up and run. Now you can see that it actually
changes the number of apples that outputs based on the arguments that we provide.
Okay so there's one more thing I'm going to show you about these function
arguments and that's that you can actually set a default for the function
arguments. Okay so a default means you can provide a default value for this so
you don't even need to provide it here. So let's just say there's a default of
seven apples, we always start with seven. The first time you call it you can
actually remove that and you can run it again and you see it still says seven we
changed the default to ten. Save that and run it. Now you can see it says ten. Now
the only thing to remember about setting defaults is you can only set defaults on
the last or multiple last items in a function argument list. So another way of
putting it is you cannot have a non default function after you...or sorry a
none default argument after you defined an argument with a default. So we wouldn't
be able to provide name equals mark as a default and then put a non default
argument here. If you try that it will give you an error telling you a
non-default argument follows a default argument. So basically once you've
defined your first default argument you need to either move it to the end of the
list like this...
oops copy that you even need to move it to
the end of the list or you need to set a default for the items in front and then
you would need to reorder when you call the function reorder the...you would
need to put the number of apples first in this case because we've changed it
around. Okay so let's just move that back just so we have a finished working
version. And yeah you can set a default for any type of argument as long as
you don't put any non default ones
after the default. Okay so that's how you create functions in Python. Thank you so
much for watching. If you have any questions at all please leave them in
the comments below and I'll try and answer them or someone else might answer them
for you. So thank you very much for watching and I'll see you in the next
video.
Không có nhận xét nào:
Đăng nhận xét