Intro to Python Flashcards

1
Q

What is a variable?

A

Usually the first line of a code, programs use variables to remember information. Variables have content and names that tell us what’s inside.

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

What do computers use variables for?

A

To remember information

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

To create a variable, we start by typing its…

A

name.

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

What do we use to create a multi-word name of a variable?

A

Snake Case. Snake case means using _ to connect additional words.

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

What do we use snake case for?

A

To create variable names with multiple words.

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

Why do variables have descriptive names like city or population instead of c or p?

A

To help us understand what’s inside of them.

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

How often can we update the value of a variable?

A

As many times as we want.

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

What type of value uses “ “ ?

A

Strings

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

Describe a String Value.

A

A string value is text between double quotes.

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

How do we know a value is a string?

A

It’s a text between double quotes, like “Liz is No. 1!”

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

What’s happening in this code?

song_name = “Hey Ya!”

A

The variable song_name stores the value of “Hey Ya!”

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

What’s the value of this variable?

hobby = “Tree Shaping”

A

“Tree Shaping”

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

What does the special instruction print() do?

A

Print() tells the computer to display a value in the console.

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

What is another name for the console?

A

The shell

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

What’s the console?

A

An area that displays output from a code

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

What’s the value of speed?

speed = 300 + 5

A

305

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

Why does this code display 31 instead of in the console?

temperature = “3” + “1”
print(temperature)

A

Because “3” and “1” are string values

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

How do we know that the score variable stores a number?

score = 40 + 4

A

Because there are no double quotes around 40 and 4.
The answer would be 44.

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

What does this code display in the console?

area = “3 * 5”
print(area)

A

3 * 5

The variable stores a string, not numbers.

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

What’s a good use for the values True and False?

A

Showing if a feature is switched on or off

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

Why is “False” not the same as False?

A

There are quotes around it, so “False” is a string

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

What is the negation operator?

A

not is the negation operator. It turns values into their opposite.

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

What does the not operator do?

A

It turns True or False values into their opposite

24
Q

What do we call the not sign in front of True and False?

A

The not sign is the negation operator

25
What is the equality operator?
The equality operator is ==
26
What do we use to check if two numbers are equal?
== We use the equality operator.
27
What do we use to check if a number is NOT equal to another number?
!= We use the inequality operator
28
What allows us to display expressions like adding a strong to a number without an error?
F-strings (Formatted strings)
29
What are the two parts of an f-string?
First the character f, then the string that we want to format.
30
What do f-strings utilize to add a different kind of value in a string?
Curly braces { } can hold numbers, integers and floats within f-strings. Curly braces can also hold variable values.
31
What are f-strings for?
For displaying different kinds of values together in a string.
32
How do we display number values with f-string?
We place them between curly braces. { }
33
How can we reuse an f-string we created?
We save it in a variable and use the variable.
34
Why is first name not a valid variable name?
Because it contains a space between first and name.
35
What is the = sign for?
It gives a value to a variable
36
What's the result of using the == operator?
A value of either True or False.
37
What do we use the > operator for?
To check if a number is greater than another number.
38
What do we call the > sign?
The greater-than operator
39
What do we call the < sign?
The less-than operator
40
What do we use the < operator for?
To check if a number is less than another number.
41
What do we use to check if a number is less than or equal to another number?
Use the less-than-or-equal to operator, <=
42
What does >= do?
It checks if a number is greater than or equal to another number.
43
What are integers?
Integers represent whole numbers without decimal places.
44
What are floats?
Floats describe floating-point numbers with one or more decimal places after a point.
45
What are booleans?
Booleans represent only two values: True and False.
46
What are values like boolens, strings and numbers called?
Types
47
What do we call whole numbers without decimal points?
Integers
48
Which type is stored inside result? result = 3.33
A float
49
What are boolean values?
True and False
50
What is variable assignment?
Storing a value inside a variable.
51
What function allows for information to be passed to the code?
input()
52
What type must be used with the input() function?
The input is always of type string.
53
What do we use the input function for?
To receive input from the user.
54
What's the type of input we capture from the user?
All input from the user is treated as a string.
55
What does the input() function do?
It reads a line from input and returns it as a string .