¡GoConqr estrena diseño! Cuéntanos qué te parece.

Fichas

Functions and Recursions Theory

Usuario eliminado El usuario ha eliminado su información de asignaturas Inglés 39 fichas

Functions and Recursions Theory

Fichas del conjunto (39)

  1. 1Function DefinitionA group of statements written for executing a specific task.
  2. 2Perks of using functions1. can be reused(need to be called and can be called again and again)
    2. long programs can be broken down and can be organised using functions
    3. Provides structure to program
    4.Reduces program size
    5.Improves readability
  3. 3Types of functionsBuilt-in
    Modules
    User-defined
  4. 4What are built in functions?Stored in standard library.
    Needs no importation.
    Makes programming easier, powerful, simpler.
  5. 5Name six type conversion built in functionsint()
    str()
    float()
    list()
    tuple()
    dict()
    (ord(), hex()...)
  6. 6what does input() built in function do?Takes input from user as a string
  7. 7What does eval() built in function do?Evaluates value of string
  8. 8What does min and max function do?Gives min and max values
  9. 9What does abs() do?Gives absolute value (positive)
  10. 10What does type(), len(), round() built-in functions do?type(): Returns type of variable
    len(): Returns length of function
    round(x,y): x gets rounded to the extent y
    eg. round(11.345, 2)
    >>>11.34
  11. 11What does range() do?range(start,stop,skip)
    Returns series of numbers between start and stop. Also values can be skipped and returned optionally, by giving skip value.
  12. 12What are python modules?Simple python(.py) files. In which functions and variables are defined. Can be called in another python file.
  13. 13What does following functions of math module do? Ceil(x) floor(x) pow(x,n) sqrt(x) log10(x) cos(x) sin(x) tan(x)-ceil(x) gives >or= number to x
    – floor(x) returns integer smaller than x or x integer.
    – pow(x, n) returns x^n
    – sqrt(x) returns square root of x.
    – log10(x) returns logarithm of x with base-10
    – cos(x) returns cosine of x in radians.
    – sin(x) returns sine of x in radians.
    – tan(x) returns tangent of x in radians.
  14. 14how are a module's details called?help()
  15. 15What does the following functions of string module do? – String.capitalize() – String.find() – String.index() – String.isalnum() – String.isalpha() – String.isdigit() – String.islower() – String.isupper() – String.join() – String.lower() – String.upper() – len() – ord() – reversed() – slice()– String.capitalize() Converts first character to Capital Letter
    – String.find() Returns the Lowest Index of Substring
    – String.index() Returns Index of Substring
    – String.isalnum() Checks Alphanumeric Character
    – String.isalpha() Checks if All Characters are Alphabets
    – String.isdigit() Checks Digit Characters
    – String.islower() Checks if all Alphabets in a String, are Lowercase
    – String.isupper() returns if all characters are uppercase characters
    – String.join() Returns a Concatenated String
    – String.lower() returns lowercased string
    – String.upper()returns uppercased string
    – len()Returns Length of an Object
    – ord()returns Unicode code point for Unicode character
    – reversed()returns reversed iterator of a sequence
    – slice()creates a slice object specified by range()
  16. 16what does randrange() do?randrange (): This method always returns any integer between given
    lower and upper limit to this method. default lower value is zero (0) and
    upper value is one(1).
  17. 17random ()This generates floating value between 0 and 1. it does not
    require any argument.
  18. 18What does randint () do?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.
  19. 19What does uniform() do?uniform (): This method return any floating-point number between two
    given numbers.
  20. 20What does random.choice(lst) do?this method is used for random selection from list, tuple or
    string.
  21. 21What does random.shuffle(lst) do?this method can shuffle or swap the items of a given list.
  22. 22What are user defined functions?These are the functions which are made by
    user as per the requirement of the user.
  23. 23What are parameters in a user defined function?When we write header of any function then the
    one or more values given to its parenthesis ( )
    are known as parameter
  24. 24What are arguments in user defined functions?argument is the value passed at the time
    of calling a function.
    • In other words the arguments are used to
    invoke a function.
  25. 25What four arguments python supports?1. Positional Arguments
    2. Default Arguments
    3. Keyword Arguments
    4. Variable Length Arguments
  26. 26What are positional arguments?Positional Arguments
    • These are the arguments which are passed( arguments must be passed for all parameters)
    in correct positional order in function.
    • If we change the position of the arguments then the answer will be changed.
  27. 27What are Default arguments?Default Arguments
    • These are the arguments through which we can provide default values to the function.
    • If we don’t pass any value to the function
    then it will take a pre defined value.
  28. 28What are Keyword arguments?Keyword Arguments
    • If a function have many arguments and we want to change the
    sequence of them then we have to use keyword arguments.
    • Biggest benefit of keyword argument is that we need not to
    remember the position of the argument.
    • For this whenever we pass the values to the function then we
    pass the values with the argument name.
  29. 29What are Variable Length Arguments?Variable Length Arguments
    • As we can assume by the name that we can pass any number of
    arguments according to the requirement. Such arguments are
    known as variable length arguments.
    • We use (*) asterik to give Variable length argument.
  30. 30What are global variables?Global (module)
    – All those names which are assigned at top level in module
    or directly assigned in interpreter.
  31. 31What are local variables?Local (function)
    – Those variables which are assigned within a loop or
    function.
  32. 32What's Recursion?Recursion is a set of code in which a function keeps calling itself till the condition is satisfied.
  33. 33Point out some drawbacks of recursion.• It uses more storage as each values is pushed in to stack.
    • If recursive call is not checked carefully then your computer
    may go out of memory.
    • It is less efficient in terms of time and speed.
  34. 34What is indirect recursion?if a function calls another function which calls its caller functionWhat is indirect recursion?
  35. 35Perks of recursions?Recursion is a technique by which we can
    solve big computational problems and this
    repeated calling, decreases the complexity of
    that problem.
  36. 36What's a 'correct' and 'sensible' recursive code?Recursive Function
    • A correct and sensible recursive code fulfills following requirements-
    • It requires a case which contain recursive calling. This base case should be reachable to given parameter / argument. It can be termed
    as stopping case which is essential to have.
    • It has a recursive case in which function calls
    itself.
  37. 37How a Recursive Function works?• In such type of execution, computer sets a stack which is known as function stack.
    • This function stack is a stack of frames.
    • At every call of function, new parameter value gets pushed to the stack. The top of the stack always contains parameter value of last call.
    • When base case evaluates to true, values from stack needs to pop out one by one and result is to be returned after calculation
  38. 383 differences b/w iteration and recursion3 differences b/w iteration and recursion
  39. 39Define Base CaseAny line where Recursive function does not invoke itself.

Información

Descripción
El usuario ha eliminado su información de asignaturas Fichas sobre Functions and Recursions Theory, creado por Usuario eliminado el 08/09/2019.
Creado por
Usuario eliminado · sep 2019
Actualizado
8 sep 2019
Visitas
25
Historial
  • Creado por Sneha Supriya · 31 jul 2019
  • Copiado por Sneha Supriya · 8 sep 2019
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?