Functions Flashcards

1
Q

Function to convert a letter to its underlying ASCII

A

ord(“a”)

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

Function to convert an integer to its corresponding ASCII

A

chr(7)

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

Common functions

A

len()
str()
print ()
int ()

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

Parameters and arguments

A

Parameters are a piece of input that the function expects, while arguments are the actual pieces of input a specific function call receives.

So, a ‘multiply’ function would potentially expect two numbers: those are the parameters. If I call ‘multiply’ with the two numbers 7 and 2 are arguments. It would then return the output, 14.

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

def currencyAmount(currency, amount)
….
….
print(currencyAmount(“GBP”,5)

A

Parameters: currency, amount
Arguments: “GBP”, 5

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

What finish the function execution?

A

return value

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

Return None

A

If a function doesn’t otherwise return anything, it return None

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

Keyword parameters sep end

A

print(“A”, “B”, “C”, sep = “”, end = “”)
print(“D”, “E”, “F”, sep = “”, end = “”)

ABCDEF

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

Keyword parameters 2

A

print(“A”, “B”, “C”, sep = “#”, end = “?”)
print (“D”, “E”, “F”, sep = “%”, end = “!”)

A#B#C#?D%E%F!

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