Найти в Дзене
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 года назад
Functions in JavaScript
A function is a reusable block of code that groups together a sequence of statements to perform a specific task. One way to create a function is by using a function declaration. Just like how a variable declaration binds a value to a variable name, a function declaration binds a function to a name, or an identifier. A function declaration does not ask the code inside the function body to run, it just declares the existence of the function. The code inside a function body runs, or executes, only when the function is called...
3 года назад
Conditional Statements in JavaScript
We’ll be covering the following concepts: So if you’re ready to learn these concepts go to the next lesson— else, read over the concepts, observe the diagram, and prepare yourself for this lesson! The if statement is composed of: The else statement: Here is a list of some handy comparison operators and their syntax: here are three logical operators: Falsy values— or evaluate to false when checked as a condition. The list of falsy values includes: Проверка на логические условия идёт слева направо,...
3 года назад
Variables in JavaScript
In short, variables label and store data in memory. It is important to distinguish that variables are not values; they contain values and represent them with a name. There are only a few things you can do with variables: There are a few general rules for naming variables: The let keyword signals that the variable can be reassigned a different value. Another concept that we should be aware of when using let (and even var) is that we can declare a variable without assigning the variable a value. In such a case, the variable will be automatically initialized with a value of undefined...
3 года назад
Introduction to JavaScript
Console The console is a panel that displays important messages, like errors, for developers. Much of the work the computer does with our code is invisible to us by default. When we write console.log() what we put inside the parentheses will get printed, or logged, to the console. It’s going to be very useful for us to print values to the console, so we can see the work that we’re doing. console.log(5); // 5 printed Comments There are two types of code comments in JavaScript: // Prints 5 to the console console.log(5); console.log(5);  // Prints 5 console.log(/*IGNORED!*/ 5);  // Still just prints 5 Data types: The first 6 of those types are considered primitive data types...
3 года назад
Основы Python
A Byte of Python (Russian) Версия 2.02 Swaroop C H (Перевод: Владимир Смоляр) Скопировал цитаты, разбавив своими комментариями. 7.1 Комментарии Комментарии – это то, что пишется после символа #, и представляет интерес лишь как заметка для читающего программу. 7.2 Литеральные константы Примером литеральной константы может быть число, например, 5, 1.23, 9.25e-3 или что-нибудь вроде 'Это строка' или "It's a string!". Они называются литеральными, потому что они «буквальны» – вы используете их значение буквально...
3 года назад
Особенности Python (из "Укус Питона")
A Byte of Python (Russian) Версия 2.02 Swaroop C H (Перевод: Владимир Смоляр) Приведённые в книге особенности Python через призму моего понимания. Примеры выделены курсивом. 4.1.1 Простой Python был выбран мною за снисходительное отношение к новичкам, которое позволит не застревать на нюансах синтаксиса, а с разбегу нырнуть в процесс разработки. 4.1.2 Лёгкий в освоении Код на Python похож на псевдокод (эскиз работы программы без нюансов синтаксиса языка). 4.1.3 Свободный и открытый Различные добавления (пакеты) в открытом доступе от энтузиастов помогают найти инструменты под многие частные обстоятельства...
3 года назад