Variable Types Flashcards
(12 cards)
Variable
Variables are nothing but reserved memory locations to store values.
Assignment Operator
( = ) . The operand to the left of the ( = ) operator is the name of the variable and the operand to the right of the ( = ) operator is the value stored in the variable.
The Five Standard Data Types
Numbers, String, List, Tuple, Dictionary
The Four Numerical Data Types
int, long, float, complex
A Complex Number
A complex number consists of an ordered pair of real floating-point numbers denoted by x + yj, where x and y are the real numbers and j is the imaginary unit.
Strings
Strings in Python are identified as a contiguous set of characters represented in quotation marks
Slice Operator
( [ ] ),( [ : ] ). Subsets of strings can be taken using the slice operator ( [ ] ) and ( [ : ] ) with indexes starting at 0 in the beginning of the string and working their way from -1 at the end of the string.
String Concatenation Operator
( + ). Used to concatenate one or more strings.
Repetition Operator
( * ). Used to duplicate a string by an integer value.
Lists
A list contains items separated by commas and enclosed within square brackets ( [ ] ). A list may contain items belonging to different data types.
Tuples
A tuple is a sequence data type that is similar to a list but enclosed in parenthesis ( ( ) ). Tuples are an immutable data type (cannot change once defined). Tuples can be thought of as a read only list.
Dictionaries
A dictionary is a collection which is unordered, mutable, and indexed using (key,value) pairs. Dictionaries are enclosed with curly bracketed ( { } ).