Keywords Flashcards

1
Q

del

A

delete from dictionary

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

except

A

Debugging: If an exception happens, do this..ex: except ValueError as e: print(e)

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

exec

A

Run a string as python. ex: exec ‘print(“hello”)’

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

finally

A

exceptions or not, finally do this no matter what. ex: finally: pass

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

for

A

loop over a collection of things. ex: for i in row:

print(i)

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

from

A
import specific parts from a module
from flask import Flask
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

global

A

make this a global variable

global x

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

if

A

if condition
if x < 9:
print(“x is less than 9”)

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

import

A

import a module

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

in

A

part of a for loop.
for word in phrase:
print(word)

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

is

A

Like == to test equality

1 is 1 == True

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

lambda

A

Create a short anonymous function.

s = lambda y: y ** y; (s)3

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

not

A

logical not
if word not in phrase:
print(“That is not in the phrase”)

not True == False

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

or

A

logical or

True or False == True

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

pass

A
Filler word. Used to create an empty suite or block.
def word():
    pass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

print

A

print this out to the console or what have you.

print(“Hello world!”)

17
Q

raise

A

raise an exception when things go wrong.

raise ValueError(“No”)

18
Q

try

A

try this block and see if it raises an exception, if so go to except:

try:
pass

19
Q

while

A

while loop

while x > 0:
if x % 2 == 0:
print(“even”)

20
Q

with

A

with an expression as a variable do…

with x as y:
pass

21
Q

yield

A

pause here and return to caller.

def X(): 
yield Y;
X().next()