So what we see here is sort of a standard layout of a typical program where we have a start and the end.
So what we're going to do here is illustrate some program structures, and I'm going to pop over to the Python spider Python interface and I'm going to enter some code in the editor window which will illustrate a couple of the initial and simplest structures and those are if statements and then we'll go back to a slide to summarize what we've seen so I'm going to start by getting a value X from the user the way that we have done it before.
And then I'm going to consider how would I square this value and preserve the sign of the value.
Now, there are different ways of doing this, for instance, using assign function.
So I'm going to start out with a simple one where I'm just going to make a calculation, SGNX2 is equal to X squared, and then I'm going to have an if statement.
If X is less than zero, colon, and you'll notice when I hit the enter key, It automatically comes down one line and forms an indent of four spaces.
And the indent must be four spaces, and that's why it assigns that automatically.
And then here I'm going to say SGNX2 is equal to minus SGNX2 to preserve the negative sign.
And then to finish off here, we will do a little print statement to display our result.
So what we see here is sort of a standard layout of a typical program where we have a start and the end.
So what we're going to do here is illustrate some program structures, and I'm going to pop over to the Python spider Python interface and I'm going to enter some code in the editor window which will illustrate a couple of the initial and simplest structures and those are if statements and then we'll go back to a slide to summarize what we've seen so I'm going to start by getting a value X from the user the way that we have done it before.
And then I'm going to consider how would I square this value and preserve the sign of the value.
Now, there are different ways of doing this, for instance, using assign function.
So I'm going to start out with a simple one where I'm just going to make a calculation, SGNX2 is equal to X squared, and then I'm going to have an if statement.
If X is less than zero, colon, and you'll notice when I hit the enter key, It automatically comes down one line and forms an indent of four spaces.
And the indent must be four spaces, and that's why it assigns that automatically.
And then here I'm going to say SGNX2 is equal to minus SGNX2 to preserve the negative sign.
And then to finish off here, we will do a little print statement to display our result.
The rest of this transcript — segmented and speaker-labeled, so you land on the exact moment something was said
Search every transcript — by keyword, by phrase, or by meaning, across every show Radar indexes
Trends — what is surging across podcasts, measured against its own baseline
Alerts — when a name you follow appears in a newly indexed episode
No account is needed to search Radar.