Basic datatypes in python are
- String
- Integer
- Float
- Complex Numbers
- Built-in datastructures
- list
- tuple
- set
- dictionary
- Built-in methods on String:
stringname.capitalize() - First letter of string is converted in uppercase
stringname.casefold() - Converts string into lower case
stringname.upper()-Coverts the whole string into uppercase.
stringname.lower()-Converts the whole string into lowercase.
stringname.count()- Prints the number of times a specific value is occurred
stringname.isnumeric() - Returs whether the values in string are numeric or not
stringname.isupper() - Returns whether the string is in uppercase or not i.e True or False
stringname.islower() - Returns whether the string is in lowercase or note i.e True or False
stringname.startswith("suffix") - Tells whether the string starts with particular suffix
stringname.endswith("prefix") - Tells whether the string ends with particular prefix
for more similar methods run print(dir("stringname"))
List
- Properties of List
- Built-in methods of List
listname.insert(index,element) - Inserts single element into the List at specific index
listname.append(element) - Inserts single element at end of the list.
listname.extend([element1,element2,element3,..,,]) - Inserts more than one elements
listname.remove(element) - removes particular element from list
listname.pop(index) - removes element with particular index from the list.
listname.count(element) - returns the number of elements with specified values.
listname.reverse() - turns list into reverse order.
for more set methods run print(dir(listname))
Sets
- Properties of Sets
Sets are unordered.Duplication of elements is allowed.Set elements are unique.Elements cannot be accessed using index.
- Built-in methods of Sets
setname.add(element) - adds single element into the set
setname.update([element1,element2,element3])- update the number of elements into the list
setname.remove(element) - Removes a particular element.
setname.pop()- pops a element from the set (It will pop any random element as its unordered)
for more set methods run print(dir(setname))
Dictionary
- Properties of Dictionary
- Built-in methods of Dictionary
Tuple
- Properties of Tuples
Comments
Post a Comment