Data Types and Structures Flashcards
What is an Integer Data Type classified by?
An integer is a data type which is a number without a decimal point and is defined by the function int().
What is an Float Data Type classified by?
A float is a data type which is a number with a decimal point and is defined by the function float().
Which function can be used to find out which data type is a certain value?
You can use the type() function.
What happens when you use the int() function on a float value?
The value after the decimal point is taken off and no rounding occurs.
What happens when you use the float() function on an integer value?
A decimal point and a 0 is appended onto the number.
What is a boolean?
A boolean is a data type that can have a value of true or false. (Created by George Bool, Boolean Algebra)
What does != mean?
!= means not equal to. (Comparison Operator)
What type of operators are and, not and or?
Logical Operators
What is a string classified by?
It is classified by double or single quotes.
How do you tell Python that this quote is in the string not the syntax?
By using a backslash. ()
What is the symbol to add and multiply strings?
+ for addition; * for multiplication
How can you reference the first item of a list?
print(list_name[0])
How can you reference the last item of a list?
print(list_name[-1]) (Not print(list name[-0])
What code do you use to slice the list from index 5 to 9?
print(list_name[5:9])
What is a tuple?
A data type for immutable ordered sequence of elements.
What is a set?
A data type for mutable unordered collections of unique elements.
What is a list?
A data type for mutable ordered list of data
Is a string mutable?
No, a string is an immutable ordered data type.
What is a dictionary in Python?
A dictionary is a data type for mutable objects that store mapping s of unique keys to values.
What is the syntax of a dictionary?
dictionary_name = {value:key, value:key, value:key}
How do you print the value with a given key in a dictionary?
print(dictionary_name[key])
How do you add value with a given key in a dictionary?
dictionary_name[New_Key] = New_Value
How do you find if an element is in a list.
print(key in dictionary_name)
What are the two identity operators?
is: evaluates if both sides have the same identity;
evaluates if both sides have different identities