python

Description

Mind Map on python, created by makspl17 on 08/20/2013.
makspl17
Mind Map by makspl17, updated more than 1 year ago
makspl17
Created by makspl17 over 11 years ago
24
1

Resource summary

python
  1. print
    1. () are needed after the command
      1. "" quotes are used when you want to use text
        1. it sends a message to output
        2. variables
          1. dont need to be declared
            1. variable types
              1. numbers
                1. integers (7, -2, 43 etc)
                  1. name = integer (eg: int = 2)
                  2. float point numbers (0.2 , 7.2 etc)
                    1. name = float (eg: float = 7.0)
                  3. strings
                    1. name = "text" or 'text' (eg: my = "hello" )
                      1. strings formating
                        1. is used to add variables to text (eg: print "%s" % name. where name is a variable)
                          1. %s - strings
                            1. %d - integers
                              1. %f - floating point integers
                                1. %.number of digitsf - floats with fixed amount of digits
                                  1. %x/%X - Integers in hex representation (lowercase/uppercase)
                                    1. basic operations
                                      1. len(string) will give the lenght of the string
                                        1. stringname.index("o") will count how far counting from zero the 'o' occures from the start
                                          1. stringname.count("L") will give the number of "L" in the string
                                            1. stringname[3,7] will give a slice (counting from zero) of the string starting at 3 and ending at 7
                                              1. stringname.upper()/lower() will convert the string to lower of upper case letters respectively
                                                1. stringname.startswith("")/endswith("") will print true or false if the string starts/ends with the given string
                                                  1. stringname.split(" ") will separate strings with the string given
                                                    1. stringname.split(" ") will make a list of the words in a string separated by the string given
                                              2. can be defined as other variables (eg: my = m + y)
                                                1. you can define many at the same time (eg: a, b = 1, 3)
                                                2. lists
                                                  1. listname = [] will create a new list
                                                    1. listname.append(1) will add 1 to the list
                                                    2. arithmetic operations
                                                      1. % used to get the remainder (eg amount left over after dividing od integers)
                                                        1. ** to make power relationships (eg 7 to the power of 2 will be: 7 ** 2)
                                                          1. conditions
                                                            1. x == 3 will return true if x equals 3
                                                              1. x != 3 will return false
                                                                1. operators
                                                                  1. two == are used to compare bolean values
                                                                    1. != is not equals operator
                                                                      1. < and > are greater and smaller operators
                                                                        1. and/or are used to make complicated boolean expressions (eg: if name== john and age == 32 print your name is...)
                                                                          1. "in" will check if the object exists in an iterable object container such as list
                                                                            1. if/elseif will do an action if the statement given is true (eg: if x == 3 print "good")
                                                                              1. if x > 15:
                                                                                1. (4 spaces) print x
                                                                                2. "not" will invert boolean values (eg:print not true will print false )
                                                                                  1. "is" does not match the values of the variables but the instances instead
                                                                                    1. eg (a = [1,2,3] b = [1,2,3] a is b. will print true but if you done b = a a is b would return true )
                                                                              2. loops
                                                                                1. for
                                                                                  1. for w in <list, array etc>
                                                                                    1. repeats fixed number of times
                                                                                    2. while
                                                                                      1. while <condition>
                                                                                        1. will repeat as long as the condition is true
                                                                                        2. continue/break are used to either skip the data block and go to the top of the loop or to stop it
                                                                                        3. functions
                                                                                          1. def functionname(arguments)
                                                                                            1. they can be called to perform a piece of code specified before
                                                                                              1. can return a variable (eg : return a will return the value of a)
                                                                                                1. functionname(arguments) will call a function
                                                                                                Show full summary Hide full summary

                                                                                                Similar

                                                                                                Python Quiz
                                                                                                karljmurphy
                                                                                                Think Python
                                                                                                tsilvo2001
                                                                                                Basic Python - Print Formatting
                                                                                                Rebecca Noel
                                                                                                What is Python?
                                                                                                Daniel Ingram
                                                                                                Python
                                                                                                54671
                                                                                                Know your Python!
                                                                                                educ8ict
                                                                                                Basic Python - Strings
                                                                                                Rebecca Noel
                                                                                                Study on IoT systems design
                                                                                                Tomasz Cieplak
                                                                                                OpenSource Programming
                                                                                                Faheem Ahmed
                                                                                                Python
                                                                                                Kirstie Wu
                                                                                                Basic Python - Lists
                                                                                                Rebecca Noel