Project 01 - Building Random CLI - Recommendation CLI

Building Command Line Tools with Python, Julia and Nodejs Module 05 - Building CLI Tools - Projects
21 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
€65.26
List Price:  €93.23
You save:  €27.97
£55.95
List Price:  £79.94
You save:  £23.98
CA$95.75
List Price:  CA$136.79
You save:  CA$41.04
A$107.23
List Price:  A$153.20
You save:  A$45.96
S$95.15
List Price:  S$135.94
You save:  S$40.78
HK$547.94
List Price:  HK$782.80
You save:  HK$234.86
CHF 63.91
List Price:  CHF 91.30
You save:  CHF 27.39
NOK kr766.40
List Price:  NOK kr1,094.90
You save:  NOK kr328.50
DKK kr486.75
List Price:  DKK kr695.39
You save:  DKK kr208.64
NZ$117.46
List Price:  NZ$167.81
You save:  NZ$50.35
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,670.29
List Price:  ৳10,958.03
You save:  ৳3,287.74
₹5,832.01
List Price:  ₹8,331.80
You save:  ₹2,499.79
RM334.37
List Price:  RM477.70
You save:  RM143.32
₦88,678.72
List Price:  ₦126,689.32
You save:  ₦38,010.60
₨19,457.85
List Price:  ₨27,798.13
You save:  ₨8,340.27
฿2,591.43
List Price:  ฿3,702.20
You save:  ฿1,110.77
₺2,274.88
List Price:  ₺3,249.97
You save:  ₺975.09
B$360.25
List Price:  B$514.66
You save:  B$154.41
R1,330.75
List Price:  R1,901.16
You save:  R570.40
Лв127.68
List Price:  Лв182.41
You save:  Лв54.73
₩96,191.02
List Price:  ₩137,421.64
You save:  ₩41,230.61
₪265.67
List Price:  ₪379.55
You save:  ₪113.87
₱4,044.82
List Price:  ₱5,778.57
You save:  ₱1,733.74
¥10,886.62
List Price:  ¥15,552.99
You save:  ¥4,666.36
MX$1,193.70
List Price:  MX$1,705.36
You save:  MX$511.66
QR254.90
List Price:  QR364.16
You save:  QR109.26
P969.33
List Price:  P1,384.82
You save:  P415.49
KSh9,413.65
List Price:  KSh13,448.65
You save:  KSh4,035
E£3,352.26
List Price:  E£4,789.16
You save:  E£1,436.89
ብር3,973.96
List Price:  ብር5,677.33
You save:  ብር1,703.36
Kz58,616.62
List Price:  Kz83,741.62
You save:  Kz25,125
CLP$66,678.07
List Price:  CLP$95,258.47
You save:  CLP$28,580.40
CN¥507.14
List Price:  CN¥724.52
You save:  CN¥217.38
RD$4,110.44
List Price:  RD$5,872.31
You save:  RD$1,761.87
DA9,401.90
List Price:  DA13,431.87
You save:  DA4,029.96
FJ$160.42
List Price:  FJ$229.18
You save:  FJ$68.76
Q543.26
List Price:  Q776.12
You save:  Q232.86
GY$14,630.45
List Price:  GY$20,901.55
You save:  GY$6,271.09
ISK kr9,795.80
List Price:  ISK kr13,994.60
You save:  ISK kr4,198.80
DH709.23
List Price:  DH1,013.23
You save:  DH303.99
L1,246.59
List Price:  L1,780.93
You save:  L534.33
ден4,020.35
List Price:  ден5,743.61
You save:  ден1,723.25
MOP$563.94
List Price:  MOP$805.67
You save:  MOP$241.72
N$1,340.22
List Price:  N$1,914.68
You save:  N$574.46
C$2,572.43
List Price:  C$3,675.06
You save:  C$1,102.63
रु9,316.74
List Price:  रु13,310.19
You save:  रु3,993.45
S/259.29
List Price:  S/370.43
You save:  S/111.14
K265.67
List Price:  K379.55
You save:  K113.87
SAR262.50
List Price:  SAR375.02
You save:  SAR112.51
ZK1,825.88
List Price:  ZK2,608.51
You save:  ZK782.63
L324.76
List Price:  L463.96
You save:  L139.20
Kč1,644.30
List Price:  Kč2,349.11
You save:  Kč704.80
Ft25,615.12
List Price:  Ft36,594.60
You save:  Ft10,979.47
SEK kr760.35
List Price:  SEK kr1,086.27
You save:  SEK kr325.91
ARS$61,118.20
List Price:  ARS$87,315.45
You save:  ARS$26,197.25
Bs482.97
List Price:  Bs689.99
You save:  Bs207.01
COP$272,384.35
List Price:  COP$389,137.18
You save:  COP$116,752.82
₡35,055.79
List Price:  ₡50,081.85
You save:  ₡15,026.05
L1,725.31
List Price:  L2,464.83
You save:  L739.52
₲519,197.15
List Price:  ₲741,742.01
You save:  ₲222,544.85
$U2,684.12
List Price:  $U3,834.62
You save:  $U1,150.50
zł281.58
List Price:  zł402.27
You save:  zł120.69
Already have an account? Log In

Transcript

Right, so welcome back again. So in this particular session, we try to see how to build the randomness CLR that we built right, as we demoed in a previous session. So let's see how to build it. So I'm just going to quit my Moodle five. Anytime I would if I'm going to create a simple file called randomness does the name of a CLR that you would call just random, anonymous white.pi. That is the basic idea.

So let's see how to build it. So the first thing is that first of all, we'll be using shebang to enable us to do that can go without it, it's still going to work. But let's add it to our CI is going to be our going to be a shebang. Right. She can't do that. Because your windows no see the effect but it's still going to work for any Unix based system.

So Thomas Kali, if the files executed to be in Python to run right. Let's see this one perfectly. Now the next thing that we need to be able to import our properties to put a pass then also need to import And then we'll be important. Some other stuff which will be important will be color for coloration to be the same color. So from color, input, color, and then see print colors. These are the basic stuff if you need it for up.

So let's see how to put it to put up a way to structure up memory and see how it's going to be used. Right? So the simple usage is going to be like this. So we're going to be our randomness. Random lists, then we're going to give a common comment that can go into movies or can be books can be blocks. Read the purpose of that.

So the purpose of this app is to randomly recommend movies blogs books, sell as many as you wish, right. So that is the basic idea. So that is one of the UCC. The net proceeds are going to be also added a limit Today is going to be limited if I set the limit to five. So that is how we wanted the user to know. So what we are going to be doing is creating an option, right an option argument called commit.

And in Musil I the best person that most of the options and I commit, I usually or commands I usually do in ways or vapes, right CAN MAKE IT resources, but it's better you make it as a way, that is a good idea. So, comment this one out the list. So I'm going to create a face mean fashion to be our main function in which give it auto strength as usual, to be simple commendation CLA, right, perfect. The list goes it without it needs to be made. Perfect. First, although we need to list both the physical path to be a path which is going to go with the normal octopus admit They're not passing the description up which is going to be through a simple recommendation CLR rights or randomization sealer so let's What does random run don't miss what are we need to be our description Now let's add our program to the program name to it by going with this option of police for the night behind broke then we supply the program nifty so it's going to be random Miss right under Miss if it's let's make a small letter that is a program name.

That is what we need so far to add a p look. Let's quit this. A blog is going to be something we will be calling the task let's say a commendation by randomization satellite that right Something interesting, something funny here, the next thing we need to do is to click on our vision. And then we're gonna push now, I think that is the basic idea. So that is what you'll be using for our app. So let's add a vision to it, which is going to be a pastor with an agreement as we laid out, now passing my long format in our chat format to be patient, then partial to modesty, then I cannot pass in the patient name, right.

So it's going to be as efficient then passing the program. So repeating the normal format of this in passing the program to program so this must be inside a string format. Prague is broke. Then I'll pass in 0.01 2.21. So we are done with it right? Then we can just set the action to be vicious.

Then continue with the help. So let's put this on as a help. Question. That is what are we need, right? So we have to do something very simple something. So now let's start all argument namespaces was going to be our namespace.

So beginning with our x, pass, pass x. Now we can actually print it out. Pretty nice to see what you're done with something very busy. Something very simple. Admit it. So we just created our parser.

If we did our vision, then you have created our namespace to store everything that you wanted to let's come back here. Inside our terminal is going to Python three then the name of the Apollo Mr. says hello We have to see everything we can to help our randomization description, then our computer is working in an efficient vertical division and get the program name or domain 0.01. Very interesting. So that is how to work with it right through IBM to build something very simple. Let's add the logic to it to be adding recommendation to so how do we add the logic to the simplest we that list first of all good r plus r dot add argument, an argument you agree with this comment? Then I'll just pass in the short format R, then I'll give it the Help is going to be by the miracle man.

So randomly run don't delete the comment. Right, then I'll give you the choice of what I would recommend to what I would recommend it I would recommend books. I want to recommend movies I want to recommend Lexie Sopranos right What about you quite so let's do the phase two for now. So now everything is splitted. So let's check on that because we do think he's passing they recommend a comment. Right let's see what is it was something I recommend is passing books recommend books right if we dominate our lives because he is able to store whatever is being passed inside our argument.

Very interesting. Now let's see how to add the logic to a disclaimer of this or come back to an ATM. No, I just quit Python. We opened Python to record it. Very interesting. Now for me, I just import random with random to help us to randomly select from a list or create a list called a list is going to pick in some stuff so we have something like this he sells right they will have another one that list Sinbad in passing, and another interesting like basin of interest, person of interest.

So these three books right, we want to randomly select from listening. So with random commute to randomly select a single choice or multiple choice. So let's see how that would be random, but choice is a single choice from the from the list. This right is giving us a Star Wars variant again, when can we stop based on interest another random choice for anything is going to give me I try to as much as everyone is always going to pick randomly one choice from it. Right pivot tool, that is for picking a single choice. So in case you want to pick multiple choices, not just one guy just come back to the same thing.

Then go with random choices, not your choice but choices and I can go straight away, then this would give us enough of a list. Please give us and if most of us drink by this giving us a format or a History taught, I can run it again, there's also going to give us something different. But the keys are to select to throw one, then I just come back to this place. This supply the key, right, the key is going to be that the number or the limit you want. Let's give it us two by two. Now I'm going to select two from the list of symbols and symbols, burnt again, I'm personally interested in Star Wars right at the basic ID.

So that's what we're trying to use to build our symbol sealer. So let's come back to this place in the list, click on our data. So we have our paths random color, there, let's add our data to it. So this is going to be our data. So I'm just going to create a book list. So let's go to our books list.

And us adding some books to the booth we're adding a simple boost like I see a bio the most popular books now going off script it very nice book, then our vision is clear enough is not enough, and a wonderful book. So these are these books right silverwood. And I can go with it in a very nice, interesting books, right? That is pretty useless. So in case I want to randomly select from this, I can work on it. So let's add that logic to it.

I'll come back to my x here. And I would say that if my asked to recommend is to go to books, then I want you to randomly pick from this our books. So as we learned from here, we have the choice to continue the same option here. So it's going to be this result going to be our random choices. Now passing my books list, like this printed out, so let's print our results. So let's save it and let's run it for this one interesting, see what you have done.

Come back to this please close this. So now Jessica with the help. Everything is working as expected, I think it's I want to recommend a book. Let's go with Tasha recommend. Now passing the book super good books, as well to print it out to unscripted. Right, give us only one book.

I run it again. Today, so tennis very, very interesting to me that our app is working very well. So let's give it a limit to be adding a limit to it. So yes, come back to this place, and go with the passer. But add a comment. And I'll go with the long format of the limit.

And then the short format of the limits right. Now Good Hope. So there's going to be set limits set. Then that is all right. So I can give it a default value. So let's do that for value.

Let's see. Two, right, so please give us two different stuff in our past this limit here as my choice is going to be key going to be our hogs got to limit, right? But this is good, but this won't be seen as a strength we have to convert this one into. So you can do it here and then run it or you can set it up. So let's try this one first. Come back again, is gonna be just us limit, say two, three, or two, then I set it off, we can clean up internet, right?

The limit is set us two. By default, if I don't supply any limits, it's going to print two for the Bible and Bible. So let's change it from here. To change from us, we just come back to this place, specify the type Is it right? For integer, don't you just get it automatically committed to it at the top of our capital. That is the basic idea that you have that so let's add some goose Some other stuff to mess with is going to be for our wish list to add movies to it, and then disable them.

So let's import our data. So I'll just have our data file here, which is all these particular. So the idea is to have all this stuff in a desert.py file. But the important is books list, just several books. And then Movies List just several movies into our app. So you can just copy this one here embedded here, or you can just import it to let's import it to input our data and ensure that our data.py file which will be part of the resources is the same location as a random is right.

From here, I can now go off with this option. Now go with data. That's booster. So we're going to look inside this data file and pick that particular list for us. Right so it gives this movie list going to pick movie list for us. So that is the basic idea.

So no more need of this. I come back to this place, too. Help movies, books. So let's add this option to TV. If that command is to go to movies, then recommended to result is go to random choice to random choices and passing my movies list by then the key is going to be x dot limit. The list printed out very interesting.

So let's run it again. And now let's come back and see what else we do. So this is phone books. So I ran it again. given us an error, the reason is given as an error is that these books list has not been imported right to the point is you have to bring the data to a piece of data. But book this so this data is referring to this data file, and then it's going to look at our data file and pick a particular list for us.

Alright, let's see. Let's run it again. So cat is running. Now if I run it is going to work perfectly for us first movie Animal Farm, George Orwell. And then this is to just make it delimit jealousy, then, as predicted by this is not nice, right? This is not user friendly, right?

It's not user friendly. So we are going to look through it to make it user friendly. It also got some beautification to it. So let's add those beautification to it and it will come to the top of my thought here. And as it decreases, then there's good recommended. Recommended right, then are passing the particular stuff I'm recommending to the user, just in that format, now passing day, x dot x dot recommended if it's going to give us this particular heading right for it, so I'll copy this one.

Paste it for Our movies CBT play a comeback. And it seems that we did. Now we have our recommended books here. Very nice, right? So we can actually add a color to it before adding color to it. Let's beautify this.

So how do we just to be looping through it to be really simple, this is normal print. So let's go with maybe this one results, and then look through it, there's going to be four result singular, in my results, plural, then we're going to print that result, right? Same thing I've done here, rupees 410, this option here. So let's leave it to it and give us a nice result. Or let's run it again. So it is a good one if I run anyone, notice it's a bit right it's given us in a format of not just a list like this, but looping through them.

This is quite nicer, so we can actually add a color to it. Now this one is separated from this one. So let's have some colors to it. So to add some color between 10 color, which everybody from here, then we didn't call it OC print. So the basic syntax for adding colors using theme color, that's just going to go with the color right at the center, then the test, then the foreground, the background, and then you can just keep the attributes and attributes must always be the least it is a big formula for working with color, and color. So let's use our same thing to beautify this one.

So we can just go with a colored so this is going to be artists that are going to go on with this one. So there's gonna be a test, good foreground of lifting blue. And then the background is going to be on white on white. This one it's come back here. Let's see two You've given us an interesting fact, right? We have to make sure that is actually working, we'll call it so let's be this must be here.

Right? It's true. This is a footprint here. So let's try it again. While also not just giving us we committed by this color is okay, but it's not the best. So let's invert it right we'll be making it blue on white.

Instead of white on blue, to be white. Then on blue, Sky see with unless, again, this is better, right? This is quite nice. So everything is working as expected. So it is quite nice, but you can make it better by simplifying the color. In a unit c print.

We'll go with the C print, the colored print, the logistics of that going to give us the same result as above. If we tried to do this with a C print, so, you can either use a colored policy prints or just copy this one here and then just pass it on top of this place. So, that is the basic idea. So we have survived up by two years cannot do cannot movies can had blogs, books, several of them today's programming books and so forth. If we can just copy them, then add it to your choices, get it which should so that's the basic idea. So this is one at elsif is duplicated, add an add on to it.

So this is meant to be an out so let's come back here. And for B you can just add an R so this would add something different like the size or the size, or music or any as you wish. You could add the data size here as well. Right, to make sure that this Movies List change to our data size. Got to make sure that this data size is found within our stuff. Copy it here, good data size.

So list two, we have data size blocks, right so let's use the design blocks to help us with that. I'll copy this one here, then on to this data size, that is going to be data size blocks, right to be looking through it and giving us our result. So let's print it here. Come back here. I thought of books let's go with data size. While I thought on official Google data size blog, data size, look very interesting and very simple.

So that is something very basic that you have that Suzanne just created else. Fashion wellness club, In just 30% of print, get a better manual supply. Like what is a peasant I know give us it's not fun Venus automatically recommend something for the person to just copy the same thing. I think you know solidity we use books, right? It is the basic idea behind it. So in a nutshell, what you need is that he is going to import our packages that he bought 10 colored secrets from them color, then just get our meat fight a little bit of our pasta, which have a vision argument about ocean argument.

Then with our choices, you can add as many as you wish. Then you can also add limit value within random to randomly choose from our list and with a limit and then pick them out. Right That's the basic idea behind ocean busha. Thank you for watching this tutorial. 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.