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

A
25
Q

What are input functions

A
26
Q

What is the syntaxes for using functions

A
27
Q

How do input functions work

A
28
Q

Uses for input functions

A
29
Q

What do input functions return by default and how can you change it

A
30
Q

How do you make comments in python and why are they useful

A
31
Q

What is pseudo code

A
32
Q

Why is pseudocode important

A
33
Q

What are the different data types in python

A
34
Q

What are strings

A
35
Q

How do you format strings

A
36
Q

How do you identify different data types

A
37
Q

What is indexing and how does it work

A
38
Q

What is negative indexing

A
39
Q

What is slicing and how does it work

A
40
Q

What are integers

A
41
Q

What math symbols/math “functions” does python support

A
42
Q

What does % mean in python

A
43
Q

What is type conversion

A
44
Q

What happens if you don’t convert user input into an int for addition

A
45
Q

How does nesting functions work

A
46
Q

What are floats

A
47
Q

Floats vs integers

A
48
Q

What does * often represent

A
49
Q

What do square brackets represent

A
50
Q

What is the round function

A
51
Q

How do you use the round function

A
52
Q

How do you specify the round function

A
53
Q

How do you format to include commas as dividers

A
54
Q

Is there a limit on how precise floats can be

A
55
Q

What are some examples of python-specific conventions

A
56
Q

What are some universal conventions in coding

A
57
Q

What is a module?

A

A module is an individual file of code that can be imported and re-used.

58
Q

What is a library?

A

A library is a collection of modules.