Intro to Python Flashcards
What is a variable?
Usually the first line of a code, programs use variables to remember information. Variables have content and names that tell us what’s inside.
What do computers use variables for?
To remember information
To create a variable, we start by typing its…
name.
What do we use to create a multi-word name of a variable?
Snake Case. Snake case means using _ to connect additional words.
What do we use snake case for?
To create variable names with multiple words.
Why do variables have descriptive names like city or population instead of c or p?
To help us understand what’s inside of them.
How often can we update the value of a variable?
As many times as we want.
What type of value uses “ “ ?
Strings
Describe a String Value.
A string value is text between double quotes.
How do we know a value is a string?
It’s a text between double quotes, like “Liz is No. 1!”
What’s happening in this code?
song_name = “Hey Ya!”
The variable song_name stores the value of “Hey Ya!”
What’s the value of this variable?
hobby = “Tree Shaping”
“Tree Shaping”
What does the special instruction print() do?
Print() tells the computer to display a value in the console.
What is another name for the console?
The shell
What’s the console?
An area that displays output from a code
What’s the value of speed?
speed = 300 + 5
305
Why does this code display 31 instead of in the console?
temperature = “3” + “1”
print(temperature)
Because “3” and “1” are string values
How do we know that the score variable stores a number?
score = 40 + 4
Because there are no double quotes around 40 and 4.
The answer would be 44.
What does this code display in the console?
area = “3 * 5”
print(area)
3 * 5
The variable stores a string, not numbers.
What’s a good use for the values True and False?
Showing if a feature is switched on or off
Why is “False” not the same as False?
There are quotes around it, so “False” is a string
What is the negation operator?
not is the negation operator. It turns values into their opposite.