Chapter 2 Functionseng 1.PDF (1)
Chapter 2 Functionseng 1.PDF (1)
• random (): This generates floating value between 0 and 1. it does not
require any argument.
random Module. . .
• randint (): This method takes 2 parameters a,b in which first
one is lower
and second is upper limit. This may return any number between these two
numbers including both limits. This method is very useful for guessing
applications.
• uniform (): This method return any floating-point number between two
given numbers.
random Module. . .
• choice (): this method is used for random selection from list, tuple or
string.
• shuffle (): this method can shuffle or swap the items of a given list.
User-defined Functions
•These are the functions which are made by
user as per the requirement of the user.
•Function is a kind of collection
of statements which are written for a specific
task.
•We can use them in any part of our
program by calling them.
•def keyword is used to make user defined
functions.
User-defined Functions . . .
•We use following syntax with def keyword
to prepare a user defined function.
def Function_Name(List_Of_Parameters):
“““docstring”””
statement(s)
After the line containing
def there should be a 4
Keyword spaces indentation, which
is also know as the body or
block of the function. Function
Definition
User-defined Functions without argument
and without return (Practical)
Function
Definition
Function Call
User-defined Functions with argument and
without return (Practical)