Values and Variable Flashcards
Define value
A number or letter
What are five type of values?
- integer
- floating-point number
- string
- list
- bool
Type(2)
Class ‘int’
Type(‘Hello,World!’)
Class’str’
Type (‘2’)
Class’str’
Is 42.0 a integer, floating-point number or a string?
Floating-point number
What are the five conditions of creating a variable?
- cannot contain spaces
- can contain letters or numbers or both
- cannot begin with a number
- underscore (____) character are allowed
- cannot contain Python’s keywords
What are 27 Python keywords?
False, none, True, and, as, assert, break, class, continue, def, del, elif, else, except, finally, for, from , global, if, import, in, is, lambda, nonlocal, not, or, pass, raise , return, try, while, with, yield
Define reassignment
Reassigning a variable with a new value. Ex. A=4. After reassigning A, now A=6
In Python, is equality a symmetric relationship? Why?
No because a=7 but 7=a is wrong. Variable cannot begin with a number
Define update
New value of variable depends on the previous value
Define initialize
To begin or start
Fun fact: example of update
»> x=2
»> x=x+1
Wow
Define increment
Updating a variable by adding 1
Define decrement
Updating a variable by subtracting 1
Why do we use variables in computers?
To make a computer manipulate data, we must tell the computer to remember the data by using variable
Define variable (3 definitions)
- Memory(RAM) location
- to which we give a name
- to which we assign a value of a particular data type
Define floating-point number
Number with sig figs or with decimals
What are the two conventional ways to name a variable?
- Camelcase ex.finalLetterGrade
2. Use underscore between words. Ex.final_letter_grade
Is Python case sensitive?
Yes
Define operator
Special symbols that represent computation like multiple or add
What are examples of operators?(add,subtract,multiple, divide, and exponent)
\+=add -= subtract *= multiple /= float/normal divide **= exponent
Define assignment statement
Creates a new variable with a new value.
Ex. A= 7
Define state diagram
Create a new variable with a new value using arrows
Ex. A —> 7
Define expression
A combination of values, variables and operators
Define statement
A unit of code that has an effect like creating a variable or displaying a value
What does a newline look like?
\n
What is an example of a strongly-typed high level language?
C or C++
What is an example of a weakly-type high level language?
Python
What does GPS stand for in programming?
Good programming style
Define weakly-type high level language
You can store any value in a variable