Transcripts
1. Course Intro: Hey, guys. Welcome
to my net area of working with
projects in Python. My name is Joel Ademar and
I'm a computer programmer. In this course, we
are going to be dealing with three
types of projects. First one, we are going to be
creating a bathtub in which users can place order and the receipt is
printed out for them. We are going to be using class instead attribute of class
for this particular project. After that, you are going
to move to JumpoGame in which the user to guess the correct meaning
of a scattered word. After which we are going
to move to what I call the promote project in
which you are going to use this special
package in Python, called Text Plub to
make test correction. Oop, you guys find this
course fun and interesting. Without any delay,
let's get started.
2. Bar Tab A: Hey, guys, welcome back to the first project we are going to be dealing with. We
are going to be building. So in this project, you are going to be
building you are going to be writing code to build a baub baub where
customer can come and place order and the receipts will be printed out for them. So that was just briefly what we are going to
write could open. So we are going to be using class method attribute
for this program. So if you want to
understand more about classes and the rest, you can check my last tutorial that simulator rets
give me Python. I explain more about
classes and methods there. So I'm not going to be doing
that in this tutorial. So let's get started. So we are going to be
writing we are going to be creating our class methods. We are going to be
using different type of methods that are going to
be our innit function. And we're going to declare our attribute for
the class also. So without the
let's get started. So I've created the file,
and the name of the file, I just put something like P, and the name of the
project is Br tub. You can name it everything, but I prefer to. So that is going to be specific to the project we are doing. So we're going to
create a class class and the name of the classes, let me just name it bar. B. So inside the class, we are going to
declare a dictionary. So the dictionary is
going to comprise all the items and
then all the menu. For example, we are
going for this Tutoria, we're going to be
creating the bar tub for maybe a small restaurant
or a bar, for a bar. So we are going to be having
the items or menu list inside that the restaurants are presently and the price in
floton with a form of dollars. So I'm just going
to hey menu sorry. Meno so I'm going to
open a dictionary. So inside the dictionary, I'm going to put names
of items or menu. Sorry, menu, I want
the program so have. So first of all, I'm
just going to in form of string and the price
is a form of integer. The price is going to
be in form of integer, and the name of the item is going to be in
form of string. So the first one is
going to be wine, and it's going to
be I'm not going to make it a specific
maybe re life price. I'm just going to put
a random price to it. Let me say $10. I know
wine can never be $10, or maybe I'm wrong. So let me say beef, cow meat or anything. So let me say that's $5. So if somebody not want wine, let's say soft drink. No. I'm not using VS code. Visual Studio code,
ID for my Python. For this Python calls, I'm using Tony Tony. I just want to use this. You can useN ID you want. You can use Visual Studio
code. You can use Atom. You can use there are plenty this thing you
can use for your coding. So I just use Tony first work. So let's say soft drink. Or soft drink. Soft drink, that's $8. Also, let's say chicken or
veggies. Let's say veggies. Veggies, which is $4. Let me add let's say chicken. So for some people that
love chicken very well. So let's say chicken,
chicken is also $10. And let me add it us chicken. So we have five items
in our bar presently. You on can process
more than this. If you wish, you can add some other things
to maybe biscuit or cookies or anything
you can think of. So I'm going to
end it in chicken. So after that, we are going
to declare the innate. Now, the innate
function of our class. I did not understand
this very well, please check on my last course. The simulating new
rules give me Python. The second tutorial,
explain more about classes before I step into
tutorial main tutorial. So in the innate function, the innate function
is going to have the attribute that the instinct that is the instinct that is going to use the
class is going to process So it's going to
be a form of function, and it's also a method. Remember, any function declared inside a class is a method. So it's going to be
underscore underscore, innate underscore. So we're going to process self. So this self we represent
the instinct of the class. So when we declare the
instinct of the class, the self will be
represented with the self will be replaced
with the instant. So it's going to process
the attribute of the class. One the girl is going to
give it two attributes. So the first attribute
we are going to give is self dot prize. You can name it
total total price or total price, price Okay. Let me just say total price. Also, the second
attribute is going to be items that it is the items you choose in when you are selecting your delicacy or what
you want from the bar. And that's going to be
a form of empty array. Remember I represent
these as default so that our total price
is defaultly zero. That is $0. And our items, you know, we can select
more than one item, so I put it in the
form of list so that anytime we
select new items, we're going to add it to the RA, and we're going to get the
final result at the end. So now we want to
declare another method, and the method we
are going to declare nest is a method
that is going to t the items to the items selected to this
place to this array. So the code is going to help the user to select the user to select due to the input
of the user and add it to the items array and
also add the price. Let me just give it a name. Let me see, d. So
inside the heart, AD is going to receive two arguments that
is self and item. But there's no variable
code item yet. This one is items. This one is just item. So you see the reason why I
put it like that later on. So inside the item
inside the method, we're going to have self
dot items, dot append item. Wait, I'm going to explain
self dot another code. Save total price plus equal to self dot menu bracket item. So in this code now, we are saying that
this program show add the item selected to this place that's basically what these lines of code means. And this second
one, we are adding the price that is
these values can see a menu in so we are
selecting the item of menu. So for each item of this one, we are selecting this one. This is the way to
assess these figures, adding the price of
the selected item here to the price to the total
price. I hope you get it. So after that, you are going
to declare another method. And this method is going
to be the one that we print out the
bill for the user. So it's going to
be print B method. A function. So we're going to self going to have
self argument, maybe also tax or service pop for the sake of so that there will not be
problem or confusion. Let me just remove tax
and leave only service. Maybe defaultly the government is going to remove
the tax on their own. So we don't need to tax the customer again or
maybe through our service, we have already taxed them. So now we are just going to calculate the money for service. So we are going to the
money for service also into what the customer
is going to pay for. So you're going to
service equal service, divided by 100 times self
self, that total price. Do you get it? So
now you are telling the program to
calculate the service. So the amount input
for the service, divided by 100 by 100 times the total the total
price of items selected. So if by any means I
selected wine and chicken, that will be $20. So my total price
is going to be $20. So ever I select
my service as ten, so this one is going
to be 10/1 or nine times $20. The
hope you get that. So after that, total our total price total Price is going to be self
dot total Chris. Remember, this is a captor P, not a small P. You can
decide to put it a small P, where just put captor P so
that it can distinguish between this total and price to see that there
are different words. So plus service. So this is going to be what the customer is
going to pay for. So after this, we are
going to round it up, we are going to declare a
flop a follop that way, that we look through the items, list the items selected, and also print the
total amount for them. So we are going to declare loop. So in this case, you are going to use for loop. So for item in self dot items. Note this item is
different from this item. So I'm saying that for items are familiar with
Python very well, should understand these items. So I'm representing each item in these items op you get it. So each item in this one, that's what I want to
access through this item. I'm going to say print a
formative string, print item. So they should print out
the item for me and also. So I put little
space between them. So you guys that's going
to distinguish between the price the item
and the price itself. So after that, I'm going
to put the program show printout price for
this specific item. So it's going to be self
self dot menu item. So it's going to
look for the item I input here, maybe wine. So wine will be input here. So it's going to look for wine and look for the value
in a lot of wine. So this was going to
be ten after all. So after that, that
is all for the i. So after that, I
want to print out my total also in form
of formal ten string. So the total is going to
be total price, total. So it's going to be this praise is going to print
out a total price. So it's going to be
total price equal. So dollar sign also inside is going to print out
this total itself. They're going to be total price. Yeah, so we are through
with the code we need to put in everything
to put everything in order. But if checked very well, there's no place for user input for user to input
maybe their name to type in what they want there's no place where
the program is accent, the program, they use
the word they want. Everything is just there. So this is what we are going to resolve in
the next tutoria. We are going to make it more interactive to the user because if you want
to run this one now, you have to run it
on the console. That is your terminal, that you have to be
imputing the bat up you have to say
from Btu import bar, so you have to declare
an instance to it, before you can be using
all the function, maybe if you use P equal to bar, you're going to be B P
dots a put in the icon. So it's a very long process. So for us to avoid this, we are going to be resolving
it in the nest eutoria. So net you guys in
the nest utoria.
3. Bar Tab B: Hey, guys, welcome back. So in this part of the tori, we are going to be making this one more interactive
to the user. So we're going to be adding
some few lines of code to it. So it's going to be interactive to the user very, very well. And to get started. So in our innate function, let's add another
variable to it that we receive the name of the user so that when we are
printing the receipt, the receipt is going to comprise the name of the user also, the name of the customer. So inside it. So it's going to accept the name of the customer and save it inside the attribute name name. So after that, um, inside our hard function, we want it to be a
loop so that when the user wants to add
maybe more than one item, the program is going to
run again and add the item again to the customer
select values. So to do that, we are going to write a program that
is going to accept the user input and the item the user want and also runs
again and asks the user, maybe the user want to
input another value. So let's declare a
variable name item. So inside the item, we have input function. So inside the item function, we can put so let me make
this own sec dot item. So we want the
user to input what he or she want and look again so that the user can pick
another or maybe choose more than two item that is
maybe wine and chicken. So we have to to look again to choose both
the wine and chicken. So to do that, you have
to select this item. You have to create
another variable. So inside the variable,
you have this function. So the function will
prompt the user what do you if you check
this one very well, there's no loop inside. So we are going to make
it create a Y loop. So the y loop is
going to be true, so that's going to run and
run and run very well. So all these ones are
going to be inside it. So after that, we have to ask the user if he or she want
to pick another item again. So print. So we're asking the user,
will you pick another item. So let's create a
variable inside it a variable, let's say answer. So to know the
answer of the user. So it's going to be inside going to have a function
input function. So we are going to tell
the user for yes for yes. So we are telling
the user to pick one for yes and zero for no. So we are going to take this
answer into a if statement. So the answer that
is what the user picks that this loop
should run again. LCV. I'll tell you the reason
why I'm using Civ not else because if the user pick mistakenly pick
five instead of zero, that may affect our code. Z is equal equal to zero break. So it's going to break the loop. So else, if the user picks
something different entirely, should parent not in the option. So as part of your assessment, you are going to make this
look more functional in the sense that when the
user press maybe five, it's going to run it's not
going to run everything again, but it's going to run
cut thus rubbish. So not in the option. So it's going to
prompt the user out what he or she choose
is not in the option. That's all for this
part of the loop. And also, in our print, I think our print is
good enough, good to go. So we don't need to
put anything there except we are going to put
the value for our service. So service, this one is item only because all
the item are used. Service is going to
there's service charges, the charges for the service. So there will be service input. So we are using this
int function to make the input be in form of integer. So if the user input anything apart from integers
going to cront an error, the code is the that's
keyword error service. So when the user or the operator in put the service charges, is going to calculate it and
add it to the total price. So after that, we want to print out the customer name
before the loop. So print in form of
formatting string O in my, we are using formattin string
because we want to pass in a variable has a value
inside the print function. So we don't want to be using
the plus or prior or comma, but this makes it more easier
and easier to understand. So a formatting string, so this will be our the name of the customer is going
to be printed out. So also in the form inside the and loop the loop
is okay as it is. And at the end of our code, we want to pray just thanks
the customer that thanks. So we've done everything
we need to do for this. A Ba project. We've not yet run
it, after we run it, we are going to see how it's
going to work effectively. So the next step to take is to declare the instinct
of our class, the instinct of our class, the instinct of our class. So to declare that if you don't understand
instinct of class, please watch my Tutorial
simulating reels game in Python. I explained a lot on that. So let's declare an instance, maybe let's say
customer equal to. So we are going to par
the instance is going to be referring to the name of the class. So it's
going to be bar. So this customer can use all the attributes and the
method inside this bar class. So this self is going to be replaced with
customer when the code runs. After that, you are going
to allocate all the method to instead of the
class customer. Also, remember it
is case sensitive. Words you are putting should be repeated here that there
won't be an arrow. So we've completed everything
we need to do everything. Trust me, everything. We
can make the code better. But for this, you've
done everything. Let's run it and see if the
code is running perfectly. He's asking me for
customer name. Let me put my name. Wow,
it's giving us an arrow. W zero, zero, about, yes, yes, yes, yes. Since we've declared a variable, we don't need to put
this zone again inside. So check your code very
well and adjust this zone. So let me try and run it again. And also inside this place, we need to remove this
service is no longer needed. So far, we are making
it more interactive. So let me start again. So customer name. What
do you want to pick? Remember, do not write anything that is
no inside displays or less going to flag and arrow, and don't represent capital
letter with small letter. So let me pick wine. So he's asking me
if I want to pray, choose another one,
let me say yes. So let me choose chicken. Asking me, I said, no,
service charge 20. So wow everything is
running perfectly. So our service charge is 20. Let's calculate everything
20/1 or nd times the total times 20 that is the total price
of this one chicken, and it's print out our receipt. So completely
writing everything. Congratulations for your success in our first project here. But as part of our assessment, you can miss this code more
better by avoiding arrows. What if I choose wine capsulator instead
of in small letter? That means it's going
to fly an arrow and it's going to
crash my program. That means you have
to use try and accept value to make the program more interact more secure to
protect your program. And also, in this ad, make it when the user input
anything that is not inside this option to run
this code again, you can use continue solas. But if you use continue,
it's going to add this value that
you've input to it. So you can empty your list, empty your list and um, just writing a few
program here to empty your list
and run it again. So it's going to run this
loop again after you empty your list to pick
the correct value. So this will be how
about this project. Top is interesting and you learn a lot about
maybe loop or class. So see you guys in
the NST project.
4. Jumble Game A: Hey, guys. Welcome back to
another part of the Tutorial. So this is the project too. And in this second project, we are going to be building
a game called Jumbo Game. That's a jumbo game. So the jumbo game is
entering word like letters, maybe name of people
maybe name like John Smith and sculting it by using some
function to shuffle it, and then we give the user
of the opportunity or the player to guess the right value or the right word we are
trying to play out. So maybe, for example, John, John might be scat out to NO JH, it is left for the user to guess right to know that we are
actually saying it is John. So this word this
game is all about. This was, maybe preview
of how the game is going to look so let's
get started in height. So first of all, in game, we are going to create
a variable that is going to comprise names. So in this tutoria, we are
going to be using fruit, for example, names of fruits. For example, we are
going to be using like six of them as our example. We have to declare a
variable that is going to comprise that's going to
have the list of fruit. Let me see fruits, maybe fruit equal to a list. So inside the list,
I'm going to pause different type of fruit inside. So first of all, in
form of integer, let me see approve let's
leave it in purple. Let's just input five
to make it simple. Five fruit inside
our program num. So the program the
user will have to guess which fruit is the correct one you
are trying to say. So, for us to proceed, we have to declare a
variable that is going to comprise the list of
the shore food name. That means the list that
we comprise is shore food, spelling of apples, shore food, spelling of banana, shoveled
spelling of purple. And in English language, I think there's a
word called anagram. Anagram is a shore food, or a spelling or the
arranging of letters. So that was what we are
going to use here also. So anagrams because
it's more than one. So anagrams is going to be an empty list because
there's no thing inside, so we are going to pause this
anagram into a function. So there will be a function
that we generate this, that will shuffle all
these letters for all these spelling
words for us and give us the shuffled one and store it inside our
anagram, our anagram. So let's declare a function
that we do that for us. Let's say jumbo, yeah, according to the name of the
code we are going to write. So jumbo is going to be the name of the function we are that is going to
shortfall everything for us. So inside is, we are going
to pass the keyword. Now we are not passing self inside because
we are not dealing with class or class level
attribute to anything. This is just pure function. So we are not passing
anything like self inside. We are just going to
pass the keyword, the argument we want the user
to input in our program. So for this one, let me see through this. So through D is the name of the, um, we are representing
each values A as food. So inside it, this where
we are going to write a program that is going to
shuffle our program itself. So let's declare A also anagram. The anagram here is different
from the anagrams here. So this one is starting
from each word. So each word that's why
I'm saying anagram. So it's going to
shuffle Apple first, generate the Ng spelling. So shuffle, banana, shuffle, and Caro dozer is
going to generate it. It's not going to generate
everything at once, but it's going to pick all the items inside
the list one by one, one by one and shuffle it. So it's going to
be this anagram is going to be you're going to be using a function name list. I'll tell you the function
the usefulness of this list. So we are going to pause
this through these inside. So this list is going to take all this apple is going to turn it into
a list like example. So for example, it's going to this apple apple no it's
a full word together. It's going to turn
it to her, comma, P, comma, see, comma, go. It's going to turn
each word into an element of a set
of the list here. It's going to turn each element, each word into an
element for anagram. So it will be able
for the program to shuffle it without any problem. So inside it, after that, we are going to shuffle
the words after the program have turn it into a list, we are
going to shuffle it. The function that
is going to help us without is called shuffle. So inside this shuffle, we are going to pass an argument so you can see here, let's say, shuffle we accept Aan array
is going to accept an array, damage an array of any array, so random state, we don't need to code the random
stat but we need an array. So we've declared the already. So we've already
declared an array. We have already turned
each word into an array in this in this part
of the program. So for example, Apple, if Apple enter this place, it's going to turn Apple
into array of words. So it's going to be A comma, P, comma C comma sorry, A com B, comma B, P, again, comma, comma He. So that was as go too so we are just going to pass the name of the variable as argument
inside dish but not something. When we are using
this keyword shuffle, we need to import something. Shuffle is a method under under a class or a
package a module called random. You are going to
import the random. You can even see the
program have already import shuffle for me from this package or
from this module. This is not the only
module you can also do from random import shuffle. So either this one or this
one is still the same thing. They are still
working the same way. But you can leave this
one because the prom, the VS code generate it itself. For me, that's one of the
advantage of using VS code. So I'm presently using VS code. That's a visual studio code. So if you use an argument
and you need to import it, it will automatically
import it for you, maybe if you forgot
or something, so there won't be an error. So let me just
comment this one out. So the program I've
already input it for me, I don't need to go extra mis
extra stress to do that. So after that, what do we
want the program to do? So we want the program to arrange all the words
together as one. So we've scattered everything
here into an array, but we want the
program also to join all the words together
into a full words bag. We don't want it to be
a comma, P commerce. There's no words we want
to print for the user. So that user will
not get confused. So now we are going to return return this is going to be words is going to
separate them dot join. This is a keyword
that is going to join all the values together. Join anagram. The keyword join we pick all the words again and
join everything together. So there won't be ansia where
we are going to be having a comma PV printed for the user so that the
user would get offused. After this, what else
do we have to do? We have to look
inside this place. You have to look
inside this array of fruit and input
it as argument. Each of them a argument
into this function. So it is going to
rearrange the spelling and print out the result for us and print out
the result for us. So we are going to
use four loops. Four remember, this
fruit is different from these fruits and it's different from this one,
this through this. This flu d is the
argument we have to pass. This fruit is we are
representing each values. Each values inside the array
of fruits as fit as fruit. So in fruits, what do you
want the program to do? So we want to program to
say anagram anagrams. Dot append. What do you want to append want
to append jumbo, and then we want to print all
the anagrams. All the val. Don't get confused yet. So this is mainly what I did. So we are passing fruit that
is each fruit you know, we represent fruit as each
values inside fruits. So we are passing it as
argument inside this function. And the function is
going to take maybe, for example, it's going to
Apple is going to be APTs. So the program, we know
that we are paxing Apple has torn Apple into a set of array and shuffle it after the program is
going to join this bag. So we want the join the final result to be stored
inside this anagram. That was what we just did. So to store something inside
this empty list, we have to use the
keyword or pad. So that was mainly what I did. So after that, we are going to print out all the anagrams. So let's run this
and see our result. Well, see our result. Our result is printing out the same thing.
There's no change. What's the problem?
What really and it's not giving any
error values for us. I think it's from this place. We don't need to
import it from this let's try to import this
one instead of this one. Let's run it again. Let me clear my console
and run it again. Wow, it's working now. So the arrows that
don't use this from CLN or UTI is another
library entirely, and the shuffle of that one is working
for different thing. So the shuffle in random
is the one we want. So you've seen it, it has changed the name of Apple
into another thing. It's even early to recognize
that this is Apple, and this one is banana, this one is carrot and
this one is Ba melon, and this one is purple. So that's what the
game is all about. And this is not all
about the game. We are still going to code
more in the next tutorial. In the next studio,
we are going to be we are going to
write code to give the player a chance to type in its own observation,
his own answer. And we are going to
giving the user live that is the amount of
time the user can try. So we are going to
be checking maybe the input of the user
is a correct value. This is what we are going to be doing in the next tutorial. See you guys in
the next tutorial.
5. Jumble Game B: Guys. Welcome back
to the second part of the second project. So this is where we are
going to finalize everything for this jumbo game project. So now we want to want to receive the input of
the user and check maybe it is correct one or not and then give the user some out timeline or amount of time the
user of chance to input a. I'm going to declare a variable which is going
to comprise an empty list. I'm going to explain
why that. So I'm going to call it answer box. This is where we are
going to be storing all the answer of the user. This is where we are
going to be storing everything inside this array. So after that, we declare our health value or
let me say live. So the live is going to be the length of the
values of fruit. If this, the fruit
we input is ten, so we give the user ten lives, that means ten trials. So if the input is just one, so it's going to be one trier. So the user have to
think very well. After that, um, I'm going to print a formative string that's
going to prompt the user. So we've already given the user hint that the
above words are fruit. So the user is not
going to be get Z, maybe a car or
name of something. So we've already given the user hint that you
are talking about fruits. I'm going to tell the user
that you have so we are going to pass value for
health or for life inside. So you have maybe
this one is ten, so going to breathe out ten. Then you have ten times triers. The user will know
that he has maybe five times trier or
two times drier. So after that, we
are going to declare a variable that's going
to accept the user input. So answer. That was the answer of
the user itself, correct. So after this, you know, the user is not just going
to input only one value. It's going to input
like p values. So we don't want
it to look I love using Y through very well
because it's save stress. So we are going to be
using Y through here. So it's going to
look the program by the amount of time you
want to want to use it. You can use four loop, no
offense, can use four loop. For this sake of this tory, I'm going to use true, y loop. So we are saying that why this expression
is true, do this. So if it's not true,
it is going to end it. So we are going to
say answer box. So first of all, the
first thing we are saying that we should have pen the answer of the
user input of the user, we are going to add to this box so that at the
end of everything when the user finished the
game is going to see the right answer
and his on option. So it's not going
to be like, Oh, I tried to do this.
I try to do this. So it's going to see he or she
is going to see after that the live is going to be subtracted by one
minus equal to one. So as this loop is running each time it's run it is going
to sub one out of it. So after that, you want to
check the input of the user and maybe the input of the
user is correct or not. So you are going to print you are going
to use If statement. I answer in fruit. Basin that, if the answer the user choose is
inside the fruit, already the program print, the program is going to
move to the next line. So after that, we are going
to re arrange this variable. We're going to change it again so that the user
can input another. You know, this particular
variables outside this loop. So each time this program runs, it's going to be using another variable
we declare answer. So we've manipulated we've manipulated this answer
variable inside this place. So go for the other one or ones. So that's going to end the loop. So else, maybe the user did
not get the right answer. So else should print. So I'm trying to make
it simple, not complex. Wrong. So it's going
to move to less n and we are going to manipulate
this and answer again, this answer variable again. So answer. So we are going to. So mainly what we do is when
the user input the ball, we are going to store
it subtract one, we are going to check maybe
the answer is correct, if it's going to
play that correct. It's going to manipulate
this answer and ask the user to input
another correct one. I wrong is going to ask the user to input
another correct answer. Any other correct answer
apart from the wrong one. When the user missed one, I try to input it
for another one. The live is going
to count it and that's not going to be
a new bodies fault. So what if the live
is now equal to zero? What are we going to do? And
how will the user know that this is the values they have to check to get
the correct one? So here, we are going to
print the anagrams for the user so that anytime this program loops
these loops runs, it's going to print out the
anagram for it, anagram. It's not going to change. It's still going to
be the same one. The same thing generated from this place is still going
to be the same thing here. So we are going to prompt the user using the
formatting string. So the user is going
to know the time left. So a para is going to
be a lie among them. So what if the user input, the life is now equal to zero. So we're going to
put a NaF statement. Then it's going to
move to the next line. So it's going to print there the revalues of the fruit
is going to print it out. After the game is over. So it's going to
print out the list. So fruit he's going to print
out the list of this stuff. So after that, we
are going to print out user by answer also. So move to the left
n. So it's going to be print in formal
formatting string also. You are going to print
out the answer box. After that, we are going
to print the loop. We are done with everything
we need to do, but not all. But for this course,
for this tutoria, we are done with
everything we need to do. You just have to run it
and see maybe it there's still some things you
need to put in place, which is going to be
part of your assessment. Let's run the program and
see maybe it's working. This caped everything for me. And you say, guess, they are both fruit. You are five trials. That is, you know, there are five fruits here. You are five trials. So input anyone correctly, okay? Because I know the
answer before. So I pull. So can you say, correct? Correct, Enter another correct. So before the correct, it print out the
anagram for me again. For your case, you can
put the anagram in this loop so that they
won't be green difference. So you print out, you can see that
it's the same thing. I hold it to the last one. So it's going to be anagram. You go to print out the
anagram, the time left, correct and another one, so bananas no cops in
the way you arrange it. It can be in another form. So banana correct. So watermelon. So can you say game over? So it print out the real
answer and my own input. So I can see that I got
everything correctly. So what if I got it wrong? Let me run it again. Long, wrong, wrong.
Let me try to get one. So actually print out all the
answer and the wrong one. So we are done with
this tutorial. For your assessment,
you can make the program more functional
in the case that if the user have input
a correct value or before and the user tries to input the
correct value again, code, the program is going
to prompt the user that they or share the right answer
already in the array, so you don't need
to input it again. With the user, you
have chance to input another one
apart from that. So mainly there or you can still make create the function so
that I can use it anytime. Also, you can create
maybe a variable that you make you
to input the list, the fruit or the items, want it to be maybe want to change it to name
of cards or anything. So you can maybe put an input, create a variable that
we have an input so that you can input all the
values or you have or you create a
dictionary or list of arrays or list of items. So the program is
going to choose randomly and print
it out for the user, and these I have to
choose the Coreton. This is all for this
Jomo game in Python. So see you guys in the last
project where we are going to be working with a
specific library. I called the last project, a promo project because it's just a tiny work very little. Just include the
library and work on it. Thank you, guys. See you
in the nest tutorial.
6. Spelling Correction: Hey, guys. Welcome to the
last part of this tutorial. This is what I call
promo project. So in this tutorial, we are going to be working with spelling collection with Python. So we are going to
be checking we are going to be taking the input of the user and
check the spelling, and then we print out the correct spelling
for the user to see. So we are going to be using a particular package in Python, which is called Text Pub. We are going to download
it or install it from our pi pi.org. So just go to your text browser and
enter this leg pipi.org. It's going to open
this page for us. We can now search for the
particular package we want, so this. You can see we have
different type, the one for German language, French, Dutch, and the rest. But we are taking the first one, simple Pythonic text processing, then sentiment analysis,
part of speech, tugging, non phrase,
pressing, and more. You can read more about that and this one we are going to use this the command
we are going to copy. So if you copy it like this, you can pass it on
your text editor. You can paste your VS code on your terminal, your VS code, or you just open your CMD or your command palette
and paste it there. It's going to
automatically store there. For example, you just have
to paste it here and click. I don't have to install
it again because I've already installed
it on my system, so I don't have to
install it again. This is what you are
just going to do. You can write this
command so you don't need to go to PiPI. You can just type this
on your command palette, your Powershell or come to your VS code terminal
and install it. Now that we've installed
the package to our system. So let's guess that
there will be some code. So we are going to be using just one class out of
all the textblo methods, so we're just going
to be using one class and some specific method
inside the class. So let's get started. So we have to install text blob. So now here we are not
importing the same thing again. But this text blob is a
class inside this package. It is the entire module
inside this package. So we have to input it
so that we can use it. This is the package itself, but these are a class inside of. So now we want to create
a variable that way. Accept the user input. I'm just going to
lame down on text. So here, it's going to prompt
can use a prompt object. So it's going to pk the user, the user Center text. So after that, I want to use a specific method
aton upon this text. So now I'm using this particular
variable uncle split. This split is if you
can see over here, I saying that going to turn
into a list of string. So what this method is doing a is going to take the input of this one because I'm using
the method on this variable. So it's going to take the
input of the user and turn it and turn each word inside the input into
an element of a list. If the user, maybe the user
input something like this. So this particular method, we turn it to
something like this. So I'm just using just
for your illustration. So if the user input
something like the name dog, so the this method, we turn this particular sentence of this particular statement, turn each word to an
element of a list. So that's the work
of this split. We are using this one so
that the code will run through each words and check
the corre spelling of it. After this, we are
going to create another variable in which the correct words
we received inside. After the program
have loop inside this place and
check the spelling and the spelling is correct or change spelling
to the correct one, so it's going to store it. We have to crect the follop that we look through this list. This one is already
a list so we have to create a follow that
will look inside the list. So what should happen? You are creating another
variable inside this. Look now is not correct
text, but I'm saying, correct w. So what I
just idea is that after looking inside this
variable inside this list a particular
inside this list. So I created another variable. So the variable, of this
particular class inside. So I'm assigning this
class to this variable, and I'm passing each element of this list as an argument of this class after I've
passed this inside. So I pass this inside so
that I can use the method of this particular class on each
of the element of the list. Correct text is this
particular variable. So I'm adding each word
to this place back. So note inside this place. Now I told you the other
time that I've assigned text blob to this
particular variable. So I can use the element or methods inside this
particular class. And one of the
method is correct. So it's going to
check each word. When this one is
looping inside it, it's going to be
checking each word. I'll be checking
the corre spelling. After checking it,
it's going to now store it inside this
particular variable. So after that, I'm going to
add empty space so that there will be space
between each words. So now let's print out
the correct text outside. So let's just sprint out in
form of formatting string. So I'm going to pass
this correct text here. So it's going to print
out correct text so that the user can
see the correct one. So let's run this
code and see maybe there's an arrow or box
that we need to fix. Now, let me input text inside. So let me say my so
instead of missing name, let me put some let
me intentionally put arrow inside this without. I'm going to see
maybe it's going to correct the name or not. So my name is let
me say Ken. Wow. Can you see the code has changed this what it thinks
is the correct one. The code is running perfectly
and is running verified. Let's check maybe can you
put only one word inside. So instead of
putting order stand, let me put something on. I know that the spell
is obviously not right. Let me check maybe the program is going to correct it for me. Wow is now working perfectly. You can see that the program actually correct the
spelling for me. Between these and this, it just look like eight
lines of code. Python is very awesome
and saving stress. Instead of me writing
all these code myself with the use of
package and modules, in Python, I can bypass
things like this. So thank you guys for
watching this tutorial. See you guys in
my nest Tutorial. Not in this particular
cos in my nest tutorial. Thank you. Love you guys.