Exercise - Solution 2

Building Command Line Tools with Python, Julia and Nodejs Module 02 - Building Command Line Tools in Python with Google's Fire
5 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€59.68
List Price:  €85.27
You save:  €25.58
£51.72
List Price:  £73.90
You save:  £22.17
CA$96.63
List Price:  CA$138.04
You save:  CA$41.41
A$106.25
List Price:  A$151.80
You save:  A$45.54
S$89.89
List Price:  S$128.42
You save:  S$38.52
HK$545.48
List Price:  HK$779.30
You save:  HK$233.81
CHF 55.66
List Price:  CHF 79.53
You save:  CHF 23.86
NOK kr698.58
List Price:  NOK kr998.02
You save:  NOK kr299.43
DKK kr445.62
List Price:  DKK kr636.63
You save:  DKK kr191
NZ$118.01
List Price:  NZ$168.59
You save:  NZ$50.58
د.إ257.03
List Price:  د.إ367.21
You save:  د.إ110.17
৳8,501.07
List Price:  ৳12,144.90
You save:  ৳3,643.83
₹6,161.36
List Price:  ₹8,802.32
You save:  ₹2,640.96
RM295.29
List Price:  RM421.86
You save:  RM126.57
₦106,186.02
List Price:  ₦151,700.82
You save:  ₦45,514.80
₨19,821.25
List Price:  ₨28,317.29
You save:  ₨8,496.03
฿2,224.63
List Price:  ฿3,178.18
You save:  ฿953.55
₺2,888.20
List Price:  ₺4,126.18
You save:  ₺1,237.98
B$378.69
List Price:  B$541.01
You save:  B$162.32
R1,229
List Price:  R1,755.79
You save:  R526.79
Лв116.74
List Price:  Лв166.78
You save:  Лв50.04
₩97,255.62
List Price:  ₩138,942.56
You save:  ₩41,686.93
₪232.73
List Price:  ₪332.48
You save:  ₪99.75
₱3,974.38
List Price:  ₱5,677.93
You save:  ₱1,703.54
¥10,344.70
List Price:  ¥14,778.77
You save:  ¥4,434.07
MX$1,307.62
List Price:  MX$1,868.11
You save:  MX$560.49
QR254.94
List Price:  QR364.22
You save:  QR109.27
P939.13
List Price:  P1,341.67
You save:  P402.54
KSh9,039.20
List Price:  KSh12,913.70
You save:  KSh3,874.50
E£3,376.66
List Price:  E£4,824.01
You save:  E£1,447.35
ብር9,992.13
List Price:  ብር14,275.08
You save:  ብር4,282.95
Kz63,827.73
List Price:  Kz91,186.38
You save:  Kz27,358.65
CLP$67,298.07
List Price:  CLP$96,144.23
You save:  CLP$28,846.15
CN¥499.04
List Price:  CN¥712.95
You save:  CN¥213.90
RD$4,417.57
List Price:  RD$6,311.09
You save:  RD$1,893.51
DA9,075.16
List Price:  DA12,965.07
You save:  DA3,889.91
FJ$157.67
List Price:  FJ$225.25
You save:  FJ$67.58
Q535.38
List Price:  Q764.86
You save:  Q229.48
GY$14,604.61
List Price:  GY$20,864.62
You save:  GY$6,260.01
ISK kr8,535.28
List Price:  ISK kr12,193.78
You save:  ISK kr3,658.50
DH634.76
List Price:  DH906.85
You save:  DH272.08
L1,168.84
List Price:  L1,669.84
You save:  L501
ден3,675.85
List Price:  ден5,251.44
You save:  ден1,575.59
MOP$561.39
List Price:  MOP$802.02
You save:  MOP$240.63
N$1,234.83
List Price:  N$1,764.12
You save:  N$529.28
C$2,570.80
List Price:  C$3,672.73
You save:  C$1,101.93
रु9,864.69
List Price:  रु14,093.01
You save:  रु4,228.32
S/246.04
List Price:  S/351.51
You save:  S/105.46
K291.55
List Price:  K416.52
You save:  K124.97
SAR262.60
List Price:  SAR375.16
You save:  SAR112.56
ZK1,667.72
List Price:  ZK2,382.55
You save:  ZK714.83
L302.71
List Price:  L432.46
You save:  L129.75
Kč1,454.36
List Price:  Kč2,077.74
You save:  Kč623.38
Ft23,487.39
List Price:  Ft33,554.86
You save:  Ft10,067.46
SEK kr656.34
List Price:  SEK kr937.68
You save:  SEK kr281.33
ARS$95,542.18
List Price:  ARS$136,494.68
You save:  ARS$40,952.50
Bs482.36
List Price:  Bs689.11
You save:  Bs206.75
COP$278,283.48
List Price:  COP$397,564.87
You save:  COP$119,281.38
₡35,393.23
List Price:  ₡50,563.92
You save:  ₡15,170.69
L1,830.12
List Price:  L2,614.57
You save:  L784.45
₲503,475.24
List Price:  ₲719,281.17
You save:  ₲215,805.93
$U2,810.15
List Price:  $U4,014.67
You save:  $U1,204.52
zł253.85
List Price:  zł362.66
You save:  zł108.81
Already have an account? Log In

Transcript

All right, so welcome back again. So in this last session of the course, we try to do a simple exercise with orders you have played with fire. So this is going to be as simple as be creating a simple COI that can add two numbers, subtract two numbers, multiply and then divide two numbers. So there's going to be a simple, simple aside to pause the video and then answer it later on and compare it to what you have done. All right, so welcome back. So let's see the workflow and the asset that you be trying to use for this class simple CLA.

There are several ways you can do it. But let's make it in this simple format. I'm just going to create our file. And then we went to call it us How simple is a calculator? I wouldn't call it us. Basic.

Let's just call call zeolite dot pie, right pivot. Let's see how to look at it. So I'm just going to import via then what you're going to do is we're going to create a function that will add another function To multiply and a function that can subtract and so forth, right and another function that can divide to decide the big parties between so let's see how to infinity phase function that is going to be used to add is going to be a diff. Let's just add that nauseam is and then my Why isn't why for the number. They're like I just putting in a special option of return x plus y, something very simple right? So it is a simple function.

So I can also do the same thing for multiply and subtract to less. There's a four subtract before we multiply there's going to be diff add, no subtract, subtract, I don't know what I did subtract, subtract without is eight bits. Then I pass him is in my Why did not pass and retain x minus y. Very simple. There's going to be the next function that we need a third function to be dif. defined a function called multiply multiply is, have you seen a mistake you made in a multiply, we call it as multiple.

Multiply, didn't passing by retain is by Why did they find out what's going to be 45. So diff divide is in a way, and I'm good to go retain s divided by y. Perfect. So that is something basically I've done unless you have to convert this class that we have done so far into theory. So by best practice, you should always at least keep a documentation. Unit documentation here is going to be add two numbers, add numbers Right pivot, then we want to do another one for subtract two, at least we have some documentation for it, this is going to be subtract, then this is going to be multiply, multiply, then the final one is going to be how to go to be deployed?

Very simple and very interesting, right? So we have created these functions, all of them are working now how do you convert it to UCLA? So we have already imported via CBT pi to enable us to convert this entire stuff into a CLA. If I just come back to this place, then go to this option of the evening. Then my fire was fire. Fair, right.

So this option, I'm going to expose everything right by default, if I go with this option, we'll just put everything. Let's leave it in this, see what you have done to Python three, then our code CLA dash dash dash dash help, I see that we have our result working perfectly well. So everything I've been exposed to say that our documentation is coming at lambaste, subtract numbers, what apply and divide. So to work with that, I can just come back to this clip of this. Let's be clear, to be add, like I'm passing the number of Lizzie 20 and then 50 go to bring it to 80. Right.

So that is how to work with it. So that is the simplest solution to it. Very interesting. Because we do same thing for multiply. It's also going to make sure that is when we and as we went along with this option, we can actually specify what you want to do. So let's go to subtract, subtract minus 25.

In case I want to make it 20 through 20. I can actually Change the position by going to 50. And agreeing with Ted then is going to keep us steady. Right? Very interesting. But I can also use the positional argument.

These are optional made by that kind of so use the option argument format by coming to the same thing. And going with that as S. Two S is going to be 50. And y is going to be a state, right? So I'll do it is still going to give us 20. So both of them work either use this particular format, or use this particular format as the power of fire. So fire gives you the option of using either position or option argument.

But with oceanographers, you have to specify them. That is a basic idea to be able to boot something very interesting with this. So congrats. And then see you in the next session. Stay blessed.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.