Mindmap
PYTHON
Inhalt der Mindmap
PYTHON
INTRODUCTION
- Interpreted
- High-Level
- General Purpose Programming Langiage
- Object Oriented
VARIABLES
- No Command for declaring variable
- TYPE CASTING
- <required_datatype>(expression)
- str(exp)
- int(exp)
- float(exp)
- <required_datatype>(expression)
- GET TYPE
- type(variable/expression)
I/O
- INPUT
- Inputs always taken in string
- input(prompt)
- OUTPUT
- Output is also given in string
- print(statement,sep="exp",end="exp")
- INPUT
CONDITIONAL STATEMENTS
- if-elif-else
LOOPS
- for loop
- for i in range(start,end,inc/dec):
- for i in list/string:
- while loop
- while(condition):
- else
- runs else block when condition is no longer true
- else
- while(condition):
- Statements to terminate
- continue
- stop current iteration and continue with the next
- break
- stops loop even if the condition is true
- pass
- if no statements we can write pass
- continue
- for loop
DATA STRUCTURES
- LIST
- To store multiple items in a single variable It can store different data types It allows duplicates It is mutable(allows changes) Lists can have lists inside a list
- list_name=[data1,data2,...]
- list_name=[]
- Convertion: list(different data type)
- Methods
- sort
- sorts the list
- list_name.sort(reverse=True|False, key=myfun)
- True->Ascending False->Descendingmyfun->returns true according to my own sort
- append
- Adds element to end of list
- list_name.append(element)
- Element can be string, number, object, variable, etc If the element is iterable like list, set, etc, then it will be added as an element
- extend
- Adds iterable to end of list
- list_name.extend(iterable)
- iterable can be list, sets, tuple, etc It adds each item as an element
- insert
- Adds element at specific position
- list_name.insert(position,element)
- Element can be string, number, object , list, etc as an object
- reverse
- reverses order of list
- list_name.reverse()
- clear
- removes all elements from list
- list_name.clear()
- length
- returns length
- x=len(list_name)
- copy
- copies specified list
- x=list_name.copy()
- count
- returns number of elements with specified value
- x=list_name.count(value)
- value can be string, number, list etc
- index
- returns index of first occurrence of specified value
- x=list_name.index(value)
- value can be string, number, list etc
- pop
- returns and removes the element at specified position default is -1 and return last element
- x=list_name.pop(position)
- remove
- returns and removes the first occurrence of element
- k=list_name.remove(element)
- sort
- STRING
- sequence of characters immutable
- Methods
- length
- returns length of string
- x=len(str_name)
- capitalize
- converts the first character to uppercase
- x=str_name.capitalize()
- casefold
- converts string into lowercase
- x=str_name.casefold()
- center
- returns a centered string with delimiter value at both ends
- x=str_name.center(length,character)
- length-> required. length of returned string character->optional.to fill missing space on each side
- count
- returns the number of times a specified value occurs in a string
- x=str_name.count(value,start,end)
- value->Required. A String. The string to value to search for start->Optional. An Integer. The position to start the search. Default is 0end->Optional. An Integer. The position to end the search. Default is the end of the string
- encode
- returns encoded version of a string
- x=str_name.encode(encoding=encoding,errors=errors)
- encoding->Optional. A String specifying the encoding to use. Default is UTF-8 errors->Optional. A String specifying the error method.
- endswith
- returns true if string ends with a specified value
- x=str_name.endswith(value,start,end)
- value->Required. The value to check if the string ends with start->Optional. An Integer specifying at which position to start the search end->Optional. An Integer specifying at which position to end the search
- find
- Searches the string for a specified value and returns the position of where it was found
- x=str_name.find(value,start,end
- value->Required. The value to search for start->Optional. Where to start the search. Default is 0 end->Optional. Where to end the search. Default is to the end of the string
- index
- Searches the string for a specified value and returns the position of where it was found
- x=str_name.index(value,start,end
- value->Required. The value to search for start->Optional. Where to start the search. Default is 0 end->Optional. Where to end the search. Default is to the end of the string
- isalnum
- Returns True if all characters in the string are alphanumeric
- x=str_name.isalnum()
- isalpha
- Returns True if all characters in the string are alphanumeric
- x=str_name.isalpha()
- isdecimal
- Returns True if all characters in the string are decimals
- x=str_name.isdecimal()
- isdigit
- Returns True if all characters in the string are digits
- x=str_name.isdigit()
- islower
- Returns True if all characters in the string are lower case
- x=str_name.islower()
- isupper
- Returns True if all characters in the string are upper case
- x=str_name.isupper()
- isnumeric
- Returns True if all characters in the string are numeric
- x=str_name.isnumeric()
- istitle
- all words first letter should be caps Returns True if the string follows the rules of a title
- x=str_name.istitle()
- join
- Joins the elements of an iterable to the end of the string
- x=delimeter.join(iterable)
- delimeter should be string
- split
- Splits the string at the specified separator, and returns a list
- x=str_name.split(delimeter, maxsplit)
- delimeter->Optional. Specifies the separator to use when splitting the string. By default any whitespace is a separator maxsplit->Optional. Specifies how many splits to do. Default value is -1, which is "all occurrences"
- lower
- converts string to lower case and returns
- x=str_name.lower()
- upper
- converts string to uppercase and returns
- x=str_name.upper()
- title
- converts string to title and returns
- x=str_name.title()
- swapcase
- returns a string where all cases are interchanged
- x=str_name.swapcase()
- startswith
- returns true if string starts with a specified value
- x=str_name.startswith(value,start,end)
- value->Required. The value to check if the string starts with start->Optional. An Integer specifying at which position to start the search end->Optional. An Integer specifying at which position to end the search
- strip
- returns string after removing any leading and trailing characters
- x=str_name.strip(characters)
- replace
- replaces a specified phrase with another specified phrase
- x=str_name.replace(oldval,newval,count)
- oldvalue->Required. The string to search for newvalue->Required. The string to replace the old value with count->Optional. A number specifying how many occurrences of the old value you want to replace. Default is all occurrences
- rindex
- Searches the string for a specified value and returns the last position of where it was found
- x=str_name.rindex(val,start,enf)
- value->Required. The value to search for start->Optional. Where to start the search. Default is 0 end->Optional. Where to end the search. Default is to the end of the string
- length
- str_name="exp"/'exp'
- TUPLES
- store items in a single variable ordered and unchangeable ( cannot change, add, remove items) can be homogenous and duplicates allowed
- tup_name=(data1,data2,..)
- if tuple has one value we need to add , at end otherwise it is treated as string
- tup_name=() / tup_name=tuple()
- Methods
- length
- returns length of tuple
- x=len(tup_name)
- count
- returns number of elements with specified value
- x=tup_name.count(value)
- index
- returns index of first occurrence of specified value
- x=list_name.index(value)
- value can be string, number, list etc
- length
- Convertion: tuple(different data type)
- LIST
Informationen
- Beschreibung
- Mindmap am PYTHON, erstellt von Sonakshi Godavarthy am 26/05/2021.
- Erstellt von
- Sonakshi Godavarthy
- Aufrufe
- 8
- Bewertung