O GoConqr está de visual novo! Conte para nós o que você achou.

Flashcards

Python & Numpy

Jojo wi Inglês 39 flashcards

Python & Numpy

Flashcards do conjunto (39)

  1. 1Which of the following is true? ?A You can override functions you import to change them. ?B You can store functions in variables. ?C Every function returns something or raises an exception. ?D All of the above.D
  2. 2—
  3. 3—
  4. 4Optional Parameter --> z3
    6
    Optional Parameter --> z
  5. 5—NoneType
    int
    function
    NoneType int function
  6. 6—? When you convert an object from one type to another that is called casting.
    int --> #str to int
    set --> #ist to set
    1--> #float to int, but information loss
    ? When you convert an object from one type to another that is called casting. int --> #str to int set --> #ist to set 1--> #floa...
  7. 7What are iterables?Objects you can iterate over are called Iterables --> list, tuple, set and dictionary
    e.g. for element in [1, 2, 3]:
  8. 8—True
    [1]
    True [1]
  9. 9Eigenschaften eines Tupels?--> tuples are immutable
    --> use them if the order of the elements is important
    True
    Eigenschaften eines Tupels?
  10. 10Eigenschaften Set?--> A set can contain only unique values
    -->? You can cast a list or tuple to set to get all the unique values
    set([1, 2, 3])
    Eigenschaften Set?
  11. 11Eigenschaften dictionary?--> A dictionary maps keys to values
    ? --> You can only use immutable objects as keys
    ? --> A tuple would work as a key, a list would not
    True
    "world"
    Eigenschaften dictionary?
  12. 12Was ist Slicing? Worauf kann ich es anwenden?--> With slicing you can get parts of sequences
    -->You can use it on list, tuple, set, str
    --> sequence[start:end:step]
    --> ”start” is inclusive, ”end” is exclusive
    --> No ”start”: 0 is used
    --> No ”end”: Go until end
    [0, 2]
    [0, 1, 2]
    [2, 3, 4, 5]
    Was ist Slicing? Worauf kann ich es anwenden?
  13. 13—[3, 4]
    [5, 3, 1]
    [1, 2, 3, 4]
    [3, 4] [5, 3, 1] [1, 2, 3, 4]
  14. 14Was ist numpy? Wie kann ich es aufrufen?--> NumPy (Numerical Python) is a Python library
    --> Has many nice mathematical features such as matrices and arrays
    import numpy as np
  15. 15Was ist ein array?--> A container for values (like a list!)
    --> All values must be of the same type
    array([1, 2, 3])
    array([[ 7, 8, 9], [10, 11, 12]])
    Was ist ein array?
  16. 16—--> Arrays have a certain number of rows and columns
    --> You can find out how many rows and columns it has with .shape
    --> The first number is the number of rows
    --> The second number is the number of columns
    (2, 3)
    --> Arrays have a certain number of rows and columns --> You can find out how many rows and columns it has with .shape --> The f...
  17. 17n = np.arrange(0, 30, 2) print(n)--> Can be used to create an array with values in a range
    --> start at 0 count up by 2, stop before 30
    array([ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28])
  18. 18reshapereshapereshape
  19. 19Resize- Difference to reshape?--> Works like np.reshape
    --> Difference: Performs operation in-place
    --> This means it doesn’t return a value, it changes the array directly
    Resize- Difference to reshape?Resize- Difference to reshape?
  20. 20o = np.linspace(0, 4, 9) print(o)Creates an array of evenly spaced numbers over an interval: return 9 evenly spaced values from 0 to 4
    array([0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. ])
  21. 21—Returns an array of specified shape and type of 1s or 0sReturns an array of specified shape and type of 1s or 0sReturns an array of specified shape and type of 1s or 0s
  22. 22print(np.eye(3))Returns an NxN sized array where the diagonal is all 1sprint(np.eye(3))
  23. 23Addition/ Subtraction/ Multiplication/ DivisionShapes must be compatible
    This is generally only the case
    if they have the same shape
    [5 7 9]
    [-3 -3 -3]
    Addition/ Subtraction/ Multiplication/ Division
  24. 24x = np.array([1, 2, 3]) y = np.array([4, 5, 6]) print(x.dot(y)-->Dotproduct
    --> 1*4 + 2*5 + 3*6
    32
  25. 25—--> NumPy supports different sizes of its types, for example int64
    --> This means the integers use 64 bits
    --> This is also the default value for int arrays
    dtype('int64')
    dtype('float64')
    --> NumPy supports different sizes of its types, for example int64 --> This means the integers use 64 bits --> This is also the ...
  26. 26What are lambda functions?--> Lambda functions are functions
    --> You need to specify arguments that the lambda function takes and what it returns
    --> You should not store lambda functions in variables (though you can): The only reason to do this would be to re-use the lambda function, but in that case a normal function is more appropriate
    -->no return needed, the return value is whatever comes after the colon
    --> The intention is to use them when you need a throwaway function that is used only once and then not again
  27. 27—[('P1', 44), ('P2', 22), ('P3', 33)][('P1', 44), ('P2', 22), ('P3', 33)]
  28. 28—[('P2', 22), ('P3', 33), ('P1', 44)]
    -->key specifies what to sort!
    [('P2', 22), ('P3', 33), ('P1', 44)] -->key specifies what to sort!
  29. 29—[0, 2, 4]
    --> works like a for loop
    [0, 2, 4] --> works like a for loop
  30. 30Structure of list comprehension?[(expression) for (variable) in (iterable) (optional if)]
    --> by putting square brackets around it you convert the entire thing to a list
  31. 31—at 0x2ab4d7cbd408>at 0x2ab4d7cbd408>
  32. 32—
  33. 33—'World''World'
  34. 34—D)D)
  35. 35—B)B)
  36. 36—--> map takes a function and a number of iterables
    --> It then applies function to every item of the iterables and returns an iterator
    --> If more than one iterable is passed then function must take that many arguments
    [0, 1, 4, 9, 16]
    --> map takes a function and a number of iterables --> It then applies function to every item of the iterables and returns an itera...
  37. 37—C)C)
  38. 38—--> filter takes a function and one iterable
    --> It then applies function to every item of the iterable and returns an iterator containing only those elements for which the function returns True
    [0, 2, 4]
    --> filter takes a function and one iterable --> It then applies function to every item of the iterable and returns an iterator con...
  39. 39—--> reduce takes a function, one iterable and an optional argument initializer
    --> It then applies function cumulatively to every item of the iterable, to reduce them to a single value
    --> If an initializer is passed it is used as the first value before using the values
    --> reduce takes a function, one iterable and an optional argument initializer --> It then applies function cumulatively to every i...--> reduce takes a function, one iterable and an optional argument initializer --> It then applies function cumulatively to every i...

Informações

Descrição
FlashCards sobre Python & Numpy, criado por Jojo wi em 03-06-2020.
Criado por
Jojo wi
Visualizações
3
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?