Keywords in Python

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

await

Pause code until results from coroutine is complete

async

Used to call this coroutine function, similar to yield from

as

Used to create an alias

def

Used to define or create a function

del

Used to delete an object

with

Used to simplify exception handling

finally

Used with exceptions, a block of code that will be executed no matter if there is an exception or not. This can be useful to close objects and clean up resources

except

Used with exceptions, what to do when an exception occurs. If an error occurs, you can define different blocks for different error types.

global

Allows you to declare a global variable inside a function then use it outside the function

for

Allows you to execute a set of statements, once for each item in a list, tuple or set, etc.

continue

Allows you to stop the current iteration continue to the next iteration of a loop

class

A blueprint for creating objects

import

A function that brings in a file containing a set of functions desired in your application

and

A logical operator. Returns True if both statements are true

or

A logical operator. Returns True if one of the statements is true.

not

A logical operator. Reverse the result, returns False if the result is true.

pass

A null statement, a statement that will do nothing. Useful as a placeholder when a statement is required syntactically but no code needs to be executed

False

Boolean value, result of comparison operations

True

Boolean value, result of comparison operations

assert

For debugging that tests a condition. Will do nothing if condition is true, will return AssertionError if assert condition evaluates to false.

return

Is used to end the execution of the function and return the result (value of the expression following the keyword) to the caller

try

It defines a block of code and tests it to see if it contains any errors

None

Represents a null value or no value at all (note None is not the sme as 0, Falso or an empty string, is a datatype of its own, only None can be None).

nonlocal

This is used to work with variables inside nested functions when the variable should not belong to the inner function

break

To break out of a loop even if the while or for condition is true

not in

To check if a value is not present in an object (eg. a list). Returns True if the specified value is not present

in

To check if a value is present in an object (eg. a list). Returns True if the specified value is present

while

To create a while loop. While loop lets you execute a set of statements so long as a condition is true

yield

To end a function, returns a generator. Only used with generators. Generators are used to calculator a series of results on demand

if

To make a conditional statement. In its simplest form │if expression: │ │ statement│

raise

To raise an exception at any point.

is

To test if two variables are equal. Returns True if both variables are the same object

is not

To test if two variables are not equal. Returns True if both variables are not the same object.

lambda

Use to create a small anonymous function, can take up any number of arguments but can only have one expression

from

Use to import specific parts of a module and not all of it

else

Used in conditional statements, 'if not this then do this' mindset

elif

Used in conditional statements, same as else if


Kaugnay na mga set ng pag-aaral

wave summation and incomplete tetanus

View Set

Chapter 12 My Psychology Pomerantz

View Set

很重要SAUNDERS Pediatric - DISORDERS( 3 )

View Set

8-1 LITERATURE ~ from I Know Why the Caged Bird Sings

View Set