Simple Python Data Flashcards

1
Q

Value

A

A fundamental thing that a program manipulates like a word or number.

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

Type of data

A
Numbers and strings 
print type(5) 
print type("Hello World! ")
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Conversion

A

print 3.14, int(3.14)

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

Variable

A

A variable is a name that refer to a value
message = “What’s up, Doc?”
n = 17
pi = 3.14159

print message
print n
print pi

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

Keyword

A
Have different function, can't be use as variable name
and as assert break class continue 
def del elif else except exec 
finally for from global if import 
in is lambda nonlocal not or 
pass raise return try while with 
yield True False None
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Statement

A

is an instruction that python can execute

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

Expression

A
combination of values, variables, operators and calls to function
print 1 + 1 
print len(“hello”)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Operator

A

special tokens that represent computations
20 + 32
hour - 1
hour * 60 + minute
minute / 60
(5 + 9) * (15 - 7)
5 ** 2 # ** is the exponentiation operator
7 // 3 # // is the integer division operator
7 % 3 # % is the modulus (or integer remainder) operator

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

Input

A

name = raw_input(“Enter your name: “)
print “Hello”, name
Note that the input from raw_input is a string so you may have to convert it by int( )

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

Updating variables

A

x = 6 # initialize x
print x
x = x + 3 # update x
print x

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