Найти в Дзене
Spped up Python
ВЕКТОРИЗАЦИЯ NUMPY Когда у вас есть 1 условие и два выбора (одно от if, другое от else), то используйте функцию NumPy — where(condition, if, else). Функция where принимает первым аргументом условие, вторым — результат выполнения условия, третьим — результат невыполнения условия. Когда у вас есть цепочка условий, используйте функцию NumPy — select(1, 2, 3). Она принимает на вход : ВЛОЖЕННЫЕ УСЛОВИЯ Иногда внутри условия может стоять ещё дополнительные условия...
3 года назад
Higher-order finctions in JavaScript
Introduction When we say the word “bake”, it calls to mind a familiar subroutine— preheating an oven, putting something into an oven for a set amount of time, and finally removing it. This allows us to abstract away a lot of the details and communicate key concepts more concisely. Higher-order functions are functions that accept other functions as arguments and/or return functions as output. This enables us to build abstractions on other abstractions, just like “We hosted a birthday party” is an abstraction that may build on the abstraction “We made a cake...
3 года назад
Loops in JavaScript
A loop is a programming tool that repeats a set of instructions until a specified condition, called a stopping condition is reached. The For Loop A for loop contains three expressions separated by ; inside the parentheses: Looping through Arrays To loop through each element in an array, a for loop should use the array’s .length property in its condition. Nested Loops When we have a loop running inside another loop, we call that a nested loop. One use for a nested for loop is to compare the elements in two arrays...
3 года назад
Arrays in JavaScript
One way we can create an array is to use an array literal. An array literal creates an array by wrapping items in square brackets []. Remember from the previous exercise, arrays can store any data type. We can also save an array to a variable. Each element in an array has a numbered position known as its index. // Обратная индексация не работает, в отличии от Python Update Elements Once you have access to an element in an array, you can update its value. // Изменение через переменную позволяет менять...
3 года назад
Scope in JavaScript
You can think of scope like the view of the night sky from your window. Everyone who lives on the planet Earth is in the global scope of the stars. The stars are accessible globally. Meanwhile, if you live in a city, you may see the city skyline or the river. The skyline and river are only accessible locally in your city, but you can still see the stars that are available globally. Blocks and Scope We’ve seen blocks used before in functions and if statements. A block is the code found inside a set of curly braces {}. Blocks help us group one or more statements together and serve as an important structural marker for our code...
3 года назад
Если нравится — подпишитесь
Так вы не пропустите новые публикации этого канала