All Python Keywords Explained | TIMESTAMPS INCLUDED | Koding with Kai

preview_player
Показать описание
Welcome! I am Kailin, a student studying computer science. My goal is to pass on my knowledge to those who may need it. YouTube helped me a lot through my course, so it's time to help back. Thank you for your support!

All Python Keywords Explained | TIMESTAMPS INCLUDED | Koding with Kai

Here is a description and list of all the keywords found in Python:

Value Keywords
True/False: Boolean value. Can set a variable to either true or false
None: same as null - no value

Operator Keywords
and: Both sides have to be true or false
or: One side needs to be true
not: Reverse bool value
in: containment check/membership operator. return true or false
eg n = Hi 'h' in n → false 'H' in n → true
is: identity check. different from == which check equality. return true id obj1 exact same as obj2

Control flow Keywords
If: conditional statement. Executes only if the expression is true
Elif: same as if, but has to follow an if, and can have as many elif after if
Else: if if or all elif is not true, then else is executed no matter what

Iteration Keywords
For: most common loop. combine for and in. iterate over a range, or through a container (for-each)
While: as long as the condition in the while loop is true, it will continue to run
break: exits the loop early
continue: skips the next loop iteration

Structure Keywords
def: define a function or class
class: used to define a class
with: context manager. Executes specific code before and after the statements you specify. Usually used with file IO.
as: access results of expression or context manager passed to with, you need to use the alias as.
pass: specify the block is blank
lambda: define a function that doesn't have a name and only has one statement where the result is returned.

Returning Keywords
return: only valid as part of a function defined with def. When the keyword is encountered, it exits the function and returns the result.
yield: like return, but a generator is returned. used to pass into pythons built-in next() to get the next value returned from the function.

Import Keywords:
import: import or include a module to use in python
from: specifies a part of a module to import
as: alias for the imported tool

Exception-Handling Keywords
try: handles exceptions/ errors. only valid with at least one other keyword used for exception handling. (except,else,finally)
except: used with try to define what to do for a specific exception
raise: raises an exception
finally: specifies code that has to be run no matter what
else: combined with try and except. Have to use at least 1 except. Executes if the except was not raised
assert: used to make sure something needs to be true.

Asynchronous Programming Keywords
async: makes a function asynchronous or coroutine
await: used in asynchronous functions to specify a point in the function where control is given back to the event loop for other functions to run. You can use it by placing the await keyword in front of a call to any async function:

Variable Handling Keywords
del: unset a variable or name. commonly used to remove indexes from a list or dictionary
global: modify a variable that isn’t defined in a function but is defined in the global scope
nonlocal: similar to global in that it allows you to modify variables from a different scope. pulling from the parent scope.

Deprecated Python Keywords
print: outputs what in its parameters on the console
exec: took code as a string and executed it

0:00 Introduction
0:33 Value Keywords (True, False, None)
2:25 Operator Keywords (and, or, not, in, is)
7:15 Control Flow Keywords (if, elif, else)
10:59 Iteration Keywords (for, while, break, continue)
16:13 Structure Keywords (def, class, with, as, pass, lambda)
22:56 Returning Keywords (return, yield)
26:48 Import Keywords (import, from, as)
29:27 Exception-Handling Keywords (try, except, raise, finally, assert)
33:34 Asynchronous Programming Keywords (async, await)
34:16 Variable Handling Keywords (del, global, nonlocal)
36:42 Deprecated Python Keywords (print, exec)
38:05 Conclusion

Artist(s) name - BVG x møndberg - Floating Dreams
Provided by Lofi Girl

#KodingWithKai #python #tutorial
Рекомендации по теме