Week 0 Functions, Variables Flashcards

1
Q

What are functions?

A

Functions are actions that the computer will already know how to perform. Ex: The computer already knows that when you’re using python, the print function means it needs to print something to the console.

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

How do you call a function?

A

You type the name of the function followed by parentheses () and if it takes an arguments, those go within the parentheses separated by commas
function(argument, argument)

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

How do you make your own function?

A

You can define a custom function using the keyword “def” followed by the function name and parentheses, then a colon. After the colon, you tab and each indented line following the colon is the definition or instructions of the new function. Then you can call the function and use it

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

What are variables

A

A variable is a container used to store data values in a program.

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

How do we use variables

A

Variables have names to identify them and values are assigned to variables using the = operator.

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

What are parameters?

A

A parameter is a placeholder used to represent a value in the parentheses following a function.

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

How do parameters work?

A

When you define a function, you specify parameters to indicate what kind of input it needs. When you call the function, you provide actual values for these parameters. This makes functions flexible and reusable because you can call them with different values.
Example:
Here’s a simple function with parameters in Python:
def greet(name):
print(“Hello, “ + name + “!”)
In this example:
name is a parameter. It’s a placeholder for the value you will pass when you call the greet function.
When you call the function, you provide an actual value (argument) for the parameter:
greet(“Alice”)
This call will output:
Hello, Alice!

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

What are conventions

A

Conventions are practices in programming languages that are important to follow but not technically necessary like syntax. They’re sort of like etiquette, a set of rules and standard practices that help to produce clean, readable code. Different languages have different conventions.

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

What are arguments?

A

Arguments are the actual values you pass to a function when you call it. These are the things parameters are placeholders for.

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

How do arguments work?

A

Here’s a simple function with an argument:
def greet(name):
print(“Hello, “ + name + “!”)
In this example:
name is a parameter in the function definition. It acts as a placeholder.
When you call the function, you provide an argument, which is the actual value for the parameter.
greet(“Alice”)
This call will output:
Hello, Alice!

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

What are side effects?

A

“side effects” refer to any situation where a function does something other than simply returning a value, such as printing to the console, altering data structures, modifying variables, or changing the state of the program in any way.

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

What is the point of main functions?

A

A main function is like a starting point of your program. You define a main function towards the top of the document with the other functions. Your main programming will be the definition of this function. Then you can call the main function to execute the code. This is useful for organizing code and is also useful if you’re important code as a module because you can use an if name statement to prevent the code from running automatically.

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

What are the most common types of interfaces?

A

Command-line interface (CLI), Graphical user interface (GUI), Menu driven interface, Question-and-answer interface

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

What are the pros and cons of the different interfaces

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

What is documentation?

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

How do you read documentation?

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

Why is it important to understand documentation

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

How do quotations work in python?

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

How do you use special formatting or f strings?

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

What are uses for special formatting

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

What are bugs

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

What is debugging

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

How does debugging work

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

Why is it called a bug

25
What are input functions
26
What is the syntaxes for using functions
27
How do input functions work
28
Uses for input functions
29
What do input functions return by default and how can you change it
30
How do you make comments in python and why are they useful
31
What is pseudo code
32
Why is pseudocode important
33
What are the different data types in python
34
What are strings
35
How do you format strings
36
How do you identify different data types
37
What is indexing and how does it work
38
What is negative indexing
39
What is slicing and how does it work
40
What are integers
41
What math symbols/math "functions" does python support
42
What does % mean in python
43
What is type conversion
44
What happens if you don't convert user input into an int for addition
45
How does nesting functions work
46
What are floats
47
Floats vs integers
48
What does * often represent
49
What do square brackets represent
50
What is the round function
51
How do you use the round function
52
How do you specify the round function
53
How do you format to include commas as dividers
54
Is there a limit on how precise floats can be
55
What are some examples of python-specific conventions
56
What are some universal conventions in coding
57
What is a module?
A module is an individual file of code that can be imported and re-used.
58
What is a library?
A library is a collection of modules.