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
Q

What is the equality operator?

A

The equality operator is ==

26
Q

What do we use to check if two numbers are equal?

A

== We use the equality operator.

27
Q

What do we use to check if a number is NOT equal to another number?

A

!= We use the inequality operator

28
Q

What allows us to display expressions like adding a strong to a number without an error?

A

F-strings (Formatted strings)

29
Q

What are the two parts of an f-string?

A

First the character f, then the string that we want to format.

30
Q

What do f-strings utilize to add a different kind of value in a string?

A

Curly braces { } can hold numbers, integers and floats within f-strings. Curly braces can also hold variable values.

31
Q

What are f-strings for?

A

For displaying different kinds of values together in a string.

32
Q

How do we display number values with f-string?

A

We place them between curly braces. { }

33
Q

How can we reuse an f-string we created?

A

We save it in a variable and use the variable.

34
Q

Why is first name not a valid variable name?

A

Because it contains a space between first and name.

35
Q

What is the = sign for?

A

It gives a value to a variable

36
Q

What’s the result of using the == operator?

A

A value of either True or False.

37
Q

What do we use the > operator for?

A

To check if a number is greater than another number.

38
Q

What do we call the > sign?

A

The greater-than operator

39
Q

What do we call the < sign?

A

The less-than operator

40
Q

What do we use the < operator for?

A

To check if a number is less than another number.

41
Q

What do we use to check if a number is less than or equal to another number?

A

Use the less-than-or-equal to operator, <=

42
Q

What does >= do?

A

It checks if a number is greater than or equal to another number.

43
Q

What are integers?

A

Integers represent whole numbers without decimal places.

44
Q

What are floats?

A

Floats describe floating-point numbers with one or more decimal places after a point.

45
Q

What are booleans?

A

Booleans represent only two values: True and False.

46
Q

What are values like boolens, strings and numbers called?

A

Types

47
Q

What do we call whole numbers without decimal points?

A

Integers

48
Q

Which type is stored inside result?

result = 3.33

A

A float

49
Q

What are boolean values?

A

True and False

50
Q

What is variable assignment?

A

Storing a value inside a variable.

51
Q

What function allows for information to be passed to the code?

A

input()

52
Q

What type must be used with the input() function?

A

The input is always of type string.

53
Q

What do we use the input function for?

A

To receive input from the user.

54
Q

What’s the type of input we capture from the user?

A

All input from the user is treated as a string.

55
Q

What does the input() function do?

A

It reads a line from input and returns it as a string .