forked from codebasics/py
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Karandeep Grover
committed
Jan 25, 2021
1 parent
87741e1
commit fb9940b
Showing
2 changed files
with
22 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
## Exercise: Decorators | ||
|
||
1. Create decorator function to check that the argument passed to the function factorial is a positive integer: | ||
1. Create a decorator function to check that the argument passed to the function factorial is a non-negative integer: | ||
|
||
``` | ||
example: | ||
factorial(-1) : raise Exception or print error message | ||
2. Create a factorial function which finds the factorial of a number. | ||
|
||
``` | ||
|
||
|
||
2. Also check that number is integer or not | ||
3. Use the decorator to decorate the factorial function to only allow factorial of non-negative integers. | ||
``` | ||
example: | ||
factorial(1.354) : raise Exception or print error message | ||
factorial(-1) : raise Exception or print error message | ||
factorial(5) : 60 | ||
``` | ||
[Solution](https://github.com/codebasics/py/blob/master/Basics/python_basicsHindi/25_decorators/25_decorators.py) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters