#30
We all saw functions and it was fun knowing about it. Today, let
me tell you about 'recursions'. Recursions are basically
functions but when inside a function you call the exact same
function, it's called recursion. This topic blows everyone's
mind, but how easy this topic is, you'll appreciate it after
reading further.
So, let's hop onto the computer screen and see how recursions
are written in Python.
The formula is correct, definitely, and absolutely correct. You
can even use this information to recursively calculate factors.
The answer is 'yes'. For example, you can write 6! as 6 × 5!.
So, what we did here is call a function inside the same function
but with a different argument n1. Now, let me teach you how
this function works.
Recursion is the process of defining something in terms of
itself, just as we did with the factorial. n = n multiplied by the
factorial of n1.
One more popular example is the calculation of the Fibonacci
series. The formula is i. Do make your own program and share
it in the comment section below.
If you need a program to calculate f6, it should output 8. The
program should follow this pattern: 1+0=1, 1+1=2, 1+3=8,
and so on.
, Sets in Python | Python Tutorial - Day #31
Everything in Python is an object. If you want a data entry in
Python with no repeated entries, you can make a set. If you
want the list that you're making to have no repetitions, we can
make 'sets' for this. Let's see the methods of sets and why it's
used. Python doesn't guarantee maintained order. Sets are
unchangeable, meaning you can't change items of a set once
they are created, and sets don't contain duplicate items. Set
items are separated by commas and enclosed within curly
brackets.
Now, let's take a quick quiz. Try to create an empty set and
check using the type function. The syntax for a set and
dictionary both start and end with a curly bracket. After this, I'll
print 'type of harry'; you must get a set. If you wrote this code,
it's absolutely wrong. This is because Python doesn't give us
maintained order in a set. That is something you should know.
In the next video, I'll tell you how to access set items.