Keywords Flashcards

1
Q

and

A

this is used when assessing truth to see if two values apply. It results in True only when both operands are true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

del

A

this is used to delete an object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

from

A

this is used when importing specific functions from a module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

not

A

this is used with truth assessments to specify the negative of the conditions (e.g. to invert the truth value)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

while

A

used for loops that continue until a condition is no longer met (or goes on forever)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

as

A

used to import a module as something else, under a different name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

elif

A

in conjunction with an if statement and followed by an else statement, used for assessing conditions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

global

A

this can be used in functions in order to modify a variable outside of the function - initialize the variable as global within the function once, then use it and it will update the variable throughout the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

or

A

used when comparing conditions (i.e. this or this) - it results to true if any of the operands are true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

with

A

used to pair up lines of code - can help to close files (not super clear on this one)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

assert

A

this is used to test assumptions. If the test isnt met then it returns an AssertionError

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

else

A

used with if statements to specify another condition that would result in set actions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

if

A

used to test a condition and then carry out a specific action if that condition is met

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

pass

A

used when something is required syntaxically but the code doesnt need to do anything

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

yield

A

like a return statement in a function, yield returns a generator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

break

A

used to end a loop

17
Q

except

A

used with try to catch exception errors

18
Q

import

A

used to import modules that can be used in a program

19
Q

print

A

used to display text on the screen

20
Q

class

A

used to define a class which includes multiple definitions for an object

21
Q

exec

A

used to execute code stored in a string

22
Q

in

A

used to test if a value is in a sequence like a list or string (e.g. if “5” in numbers)

23
Q

raise

A

similar to except, this is used to raise an error (Im not quite sure how they differ)

24
Q

continue

A

continues from the beginning of the loop. unlike pass, continue starts the loop over, while pass simply does nothing and the next line of code is executed

25
Q

finally

A

used with try, except, else blocks in order to clean up resources at the end (not sure what this means)

26
Q

is

A

returns true if two objects are the same, false if they are not

27
Q

return

A

returns a value from a function to be used outside of the function

28
Q

def

A

defines a function that can be used throughout the program

29
Q

for

A

starts a for loop which iterates over a set

30
Q

lambda

A
anonymous, inline function - seems useful for quick functions
    example:
        a = lambda x: x*2
        for i in range(1,6):
            print(a(i))
31
Q

try

A

this is used with except and raise in order to catch exceptions in code that could otherwise crash the code