Переводим фразы и предложения | английский для программирования
Оригинальный шортс на английском: https://clck.ru/3Q6mdk Мой перевод и адаптация: https://clck.ru/3QHTnC Текст из видео: What is function in Python? Let’s say you really need to figure out what 1 + 2 is So you need to create a Python script to do this for you Sure you can type print 1 + 2 but what’s the fun in that? Let’s instead build a function to do it for us Let’s call it add with an input of X and Y Next let’s return X + Y With an input of x and y Next let’s return x + y So let’s try this function with an input of 1 and 2 And everything works Except this takes up three whole lines of code What a waste of space Let’s optimize this! Let’s instead use a specific function Specific functions are the same as regular functions like up here Except they’re typically only used in one use cases It’s denoted by typing function And after that we give it its input arguments X and Y Just like our add function up here We’ll do colon and then we write a one-line expression In this case it’s just X + Y Which is what gets returned No need to type the return keyword This all gets enclosed in parentheses And then our inputs 1 and 2 go here in parentheses So let’s run this and there we go! Мой телеграм канал: @scratch_coding --- Авторы: Фоны: https://clck.ru/3QHTos Музыка: https://clck.ru/3QHTqP
Оригинальный шортс на английском: https://clck.ru/3Q6mdk Мой перевод и адаптация: https://clck.ru/3QHTnC Текст из видео: What is function in Python? Let’s say you really need to figure out what 1 + 2 is So you need to create a Python script to do this for you Sure you can type print 1 + 2 but what’s the fun in that? Let’s instead build a function to do it for us Let’s call it add with an input of X and Y Next let’s return X + Y With an input of x and y Next let’s return x + y So let’s try this function with an input of 1 and 2 And everything works Except this takes up three whole lines of code What a waste of space Let’s optimize this! Let’s instead use a specific function Specific functions are the same as regular functions like up here Except they’re typically only used in one use cases It’s denoted by typing function And after that we give it its input arguments X and Y Just like our add function up here We’ll do colon and then we write a one-line expression In this case it’s just X + Y Which is what gets returned No need to type the return keyword This all gets enclosed in parentheses And then our inputs 1 and 2 go here in parentheses So let’s run this and there we go! Мой телеграм канал: @scratch_coding --- Авторы: Фоны: https://clck.ru/3QHTos Музыка: https://clck.ru/3QHTqP
