Frameworks 005 Flashcards

1
Q

What is a function?

A

A Function is a piece of code that you can reuse by calling its name.

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

What is a benefit in the end of using functions whenever you can?

A

It allows us to make less mistakes when writing code as we do not need to rewrite more code.

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

What is this an example of?:
def hello():
print(“Hello User”)

hello()

A

A function.

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

What will this print?:
def ten_squared():
return 10**2

x = ten_squared()
print(x)

A

100

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

What will this print?:
def sum(num1, num2):
return num1+num2

x = sum(5, 10)
print(x)

A

15

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

How many things should a function do?

A

1 or 2 at the most as it could be easy to get the wrong value and is harder to debug if longer than 1 to 2.

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

What are args?

A

They are when you input multiple arguments into a function.

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

What are kwargs?

A

They are when you specify different variables to be inputted into a function.

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