Maths Functions Flashcards

1
Q

Power Of

A

**

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

Round Down

A

//

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

Remainder

A

%

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

Precedence

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

Strings use escape characters

A

x = “Her name's "Elizabeth"”

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

id(varName)

A

This gives the address

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

type(varName)

A

This gives the type, like ‘int’

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

Name 7 types

A

bool, int, float, string, tuple, list and dict

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

Casting

A

varName = int(10.5)

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

Multiline string

A

’’’ OR ‘’’\ The 2nd version escapes the carriage return

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

Define a Tuple

A

varTuple = (1,2,3,4)

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

Define a List

A

varList = [1,2,3,4)

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

Define a Dict

A

varDict = {‘a’:1, ‘b’:2}

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

Get items 2 and 3 from a list

A

varList[1:2]

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

While

A

While a<100:
print(a)
a+=1

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

For data in

A

For data in [1,2,3,4]:

print (data)

17
Q

For data in

A
s
t
r
i
n
g
18
Q

enumerate

A

for key, data in enumerate(‘strings’):

19
Q

try syntax

A
tuple = (1,2,3,4,5)
try:
    tuple.append(6)
except AttributeError as e:
    print("error", e)
except IOError as e:
    print("ioerror", e)
else:
    for each in tuple:
        print tuple
20
Q

When is an exception thrown

A

As soon as the error is hit

21
Q

loop - break and continue

A

break breaks out of the loop

continue jump to next iteration

22
Q

Does “else” also work in for loops

A

yes, always gets run assuming successful loop through

23
Q

How do you work back to front on a list

A

list[-1]

24
Q

length of a list

A

print(len(listName))

25
Q

How do you 2 step through a list

A

list[2:4:2]

26
Q

How do you 2 step through a list to the end, no matter where it is?

A

list[2::2]

27
Q

How do you 3 step through a list from the start to item 4 ?

A

list[:3:3]