Week 2 Flashcards
What is a value
A number or string that can be stored in a variable or computed in an expression.
What is an object
Something that can be used. i.e. kez = turtle.Turtle(). kez is an object and that object has all of the method and attributes associated with the class turtle.
What are classes
define objects (i.e car is an object of the class vehicles) Classes are a group of objects (i.e. turtle is a class and within that class are held all the methods and attributes associated with the class turtle, i.e. all the things it can do).
What function would you use to change one type to a different type?
int( to change it to whole numbers)
str( to change it to a string)
float(to change it to decimal point numbers)
What is a variable
A name that refers to a value
What does an assignment statement do
Creates a new variable and gives it a name.
What is the assignment token/operator
=
What is illegal in a variable name
It can’t start with a number, but digits can be in the name.
Can not be any of the keywords.
Can not have any white space, but can contain _
For convention purposes programmers generally use lower case.
What is a statement
It is an instruction that python can interpret and execute.
Example: while, for, if and import
What is an expression
Combination of values, variables & operators.
Expressions need to be executed.
What does the len() function do
returns the number of characters in the string.
What is an operator
They are special tokens that represent computation.
Example: + - * / ** // %
What does the operator // do?
It is called an integer division. divides and then rounds down to the nearest integer.
What does the operator % do?
The modulus operator or remainder. After dividing it will return the value of the integer remaining.
Example: 11/4 = 2.75. 11%4 = 3 (11-8)
What does the input() function do?
It asks the user what value they want to use.
The answer from the users will always in a string.