├── review.txt ├── lirik ├── README.MD ├── .ropeproject │ ├── history │ ├── objectdb │ ├── globalnames │ └── config.py ├── scrap_judul.py ├── cari_judul_1.py └── cari_judul.py ├── for_2.py ├── .ropeproject ├── history ├── objectdb ├── globalnames └── config.py ├── README.md ├── for_1.py ├── scrap_localhost_roti.txt ├── else_if.py ├── yes_no.py ├── if_.py ├── elif_.py ├── note.txt └── menu.py /review.txt: -------------------------------------------------------------------------------- 1 | some text -------------------------------------------------------------------------------- /lirik/README.MD: -------------------------------------------------------------------------------- 1 | Niatnya sih bikin robot pencari lirik lagu 2 | 3 | -------------------------------------------------------------------------------- /for_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | i = 10 4 | for i in range(i): 5 | print i 6 | -------------------------------------------------------------------------------- /.ropeproject/history: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gandhi-wibowo/python/master/.ropeproject/history -------------------------------------------------------------------------------- /.ropeproject/objectdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gandhi-wibowo/python/master/.ropeproject/objectdb -------------------------------------------------------------------------------- /.ropeproject/globalnames: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gandhi-wibowo/python/master/.ropeproject/globalnames -------------------------------------------------------------------------------- /lirik/.ropeproject/history: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gandhi-wibowo/python/master/lirik/.ropeproject/history -------------------------------------------------------------------------------- /lirik/.ropeproject/objectdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gandhi-wibowo/python/master/lirik/.ropeproject/objectdb -------------------------------------------------------------------------------- /lirik/.ropeproject/globalnames: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gandhi-wibowo/python/master/lirik/.ropeproject/globalnames -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python 2 | Its my python repository 3 | i will put all of my python code here 4 | from zero to unknown 5 | 6 | 7 | 8 | 9 | My Code 10 | My Adventure 11 | -------------------------------------------------------------------------------- /for_1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | string = "nama saya gandhi wibowo" 4 | 5 | for i, j in enumerate(string): 6 | if j == 'n': 7 | print "index dari huruf " ,j, " adalah ",i 8 | -------------------------------------------------------------------------------- /scrap_localhost_roti.txt: -------------------------------------------------------------------------------- 1 | 500 2 | Gram 3 | tepung terigu 4 | 2 5 | Butir 6 | telur 7 | 1 8 | SDM 9 | mentega 10 | 300 11 | Mili 12 | santan 13 | 300 14 | Mili 15 | air bersih 16 | 5 17 | SDM 18 | vanili 19 | 5 20 | SDM 21 | garam 22 | 125 23 | Gram 24 | gula pasir 25 | 5 26 | SDM 27 | Beking powder 28 | 5 29 | SDM 30 | ragi instan 31 | -------------------------------------------------------------------------------- /else_if.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | angka1 = raw_input("Masukkan nilai pertama : ") 3 | angka1 = int(angka1) 4 | 5 | angka2 = raw_input("Masukkan nilai kedua : ") 6 | angka2 = int(angka2) 7 | 8 | if angka1 == angka2 : 9 | print "%d sama dengan %d"%(angka1,angka2) 10 | else : 11 | print "%d tidak sama dengan %d"%(angka1,angka2) 12 | 13 | -------------------------------------------------------------------------------- /yes_no.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | question = " " 4 | 5 | while question != '' or question[0].lower() != 'y' and question[0].lower() != 'n': 6 | question = raw_input("yes or no : ") 7 | if question[0].lower() == "y": 8 | print "you chose Yes " 9 | elif question[0].lower() == "n": 10 | print "you chose No" 11 | -------------------------------------------------------------------------------- /if_.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | angka1 = raw_input("Masukkan nilai pertama : ") 3 | angka1 = int(angka1) 4 | 5 | angka2 = raw_input("Masukkan nilai kedua : ") 6 | angka2 = int(angka2) 7 | 8 | if angka1 == angka2 : 9 | print "%d sama dengan %d"%(angka1,angka2) 10 | if angka1 != angka2 : 11 | print "%d tidak sama dengan %d"%(angka1,angka2) 12 | if angka1 < angka2 : 13 | print "%d kurang dari %d"%(angka1,angka2) 14 | if angka1 > angka2 : 15 | print "%d lebih dari %d"%(angka1,angka2) 16 | if angka1 <= angka2 : 17 | print "%d kurang / sama dengan %d"%(angka1,angka2) 18 | if angka1 >= angka2 : 19 | print "%d lebih / sama dengan %d"%(angka1,angka2) 20 | 21 | -------------------------------------------------------------------------------- /lirik/scrap_judul.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import urllib2 4 | from bs4 import BeautifulSoup 5 | 6 | url = "http://www.wowkeren.com/seleb/peterpan/lirik.html" 7 | base_url = "http://www.wowkeren.com" 8 | 9 | def CariJudul(url): 10 | page = urllib2.urlopen(url).read() 11 | soup = BeautifulSoup(page,'lxml') 12 | link = [x.findAll("a") for x in soup.findAll("div",{"id":"IsiUmum"})] 13 | for judul in range(len(link)): 14 | if link[judul]: 15 | for j, i in enumerate(link[judul]): 16 | print j,i.text 17 | data=[base_url+i['href']] 18 | return data 19 | 20 | CariJudul(url) 21 | -------------------------------------------------------------------------------- /elif_.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | angka1 = raw_input("Masukkan nilai Pertama : ") 3 | angka1 = int(angka1) 4 | 5 | angka2 = raw_input("Masukkan nilai kedua : ") 6 | angka2 = int(angka2) 7 | 8 | if angka1 == angka2 : 9 | print "%d sama dengan %d"%(angka1,angka2) 10 | elif angka1 != angka2 : 11 | print "%d tidak sama dengan %d"%(angka1,angka2) 12 | elif angka1 < angka2 : 13 | print "%d kurang dari %d"%(angka1,angka2) 14 | elif angka1 > angka2 : 15 | print "%d lebih dari %d"%(angka1,angka2) 16 | elif angka1 <= angka2 : 17 | print "%d kurang / sama dengan %d"%(angka1,angka2) 18 | elif angka1 >= angka2 : 19 | print "%d lebih / sama dengan %d"%(angka1,angka2) 20 | 21 | -------------------------------------------------------------------------------- /lirik/cari_judul_1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import re 4 | import sys 5 | import urllib2 6 | from bs4 import BeautifulSoup 7 | 8 | 9 | ''' 10 | cari daftar lagu berdasarkan nama grup band dari link www.wowkeren.com 11 | ''' 12 | if len(sys.argv) <2: 13 | print "Usage : "+ sys.argv[0] +" Group Band" 14 | print "Example :"+ sys.argv[0] +" peterpan" 15 | 16 | band = sys.argv[1] 17 | url = 'http://www.wowkeren.com/seleb/'+band+'/lirik.html' 18 | html = urllib2.urlopen(url).read() 19 | soup = BeautifulSoup(html,'lxml') 20 | data = [x.findAll("a") for x in soup.findAll("div",{"id":"IsiUmum"})] 21 | for dl in range(len(data)): 22 | if data[dl]: 23 | for index,i in enumerate(data[dl]): 24 | print i 25 | -------------------------------------------------------------------------------- /lirik/cari_judul.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import re 4 | import sys 5 | import urllib2 6 | from bs4 import BeautifulSoup 7 | 8 | 9 | ''' 10 | cari daftar lagu berdasarkan nama grup band dari link www.wowkeren.com 11 | ''' 12 | if len(sys.argv) <2: 13 | print "Usage : "+ sys.argv[0] +" Group Band" 14 | print "Example :"+ sys.argv[0] +" peterpan" 15 | 16 | band = sys.argv[1] 17 | url = 'http://www.wowkeren.com/seleb/'+band+'/lirik.html' 18 | html = urllib2.urlopen(url).read() 19 | soup = BeautifulSoup(html,'lxml') 20 | data = [x.findAll("a") for x in soup.findAll("div",{"id":"IsiUmum"})] 21 | for dl in range(len(data)): 22 | if data[dl]: 23 | for index,i in enumerate(data[dl]): 24 | print i['href']+" "+i.text 25 | #print link[str(index+1)] 26 | #i.text : judul lagunya 27 | #i[href] : link lirik 28 | # print ")"+ i.text 29 | -------------------------------------------------------------------------------- /note.txt: -------------------------------------------------------------------------------- 1 | x = list('google') 2 | 3 | for i, j in enumerate(x): 4 | print i, j 5 | 6 | 7 | Note: i adalah index 8 | j adalah datanya 9 | 10 | Output : 11 | 0 g 12 | 1 o 13 | 2 0 14 | 3 g 15 | 4 l 16 | 5 e 17 | ____________________________________________________________________________ 18 | 19 | Note : split() fungsi untuk membuat suatu variable menjadi list 20 | split('/')[-1] : artinya, pisahkan string dari suatu variable dengan '/' adalah pembatasnya, lalu ambil yang paling akhir 21 | sample : nama= "Gandhi / wibowo / adalah / nama / pemberian" 22 | nama.split("/") 23 | gandhi 24 | wibowo 25 | adalah 26 | nama 27 | pemberian 28 | 29 | nama.split("/")[-1] 30 | pemberian 31 | 32 | ___________________________________________________________________________ 33 | 34 | import codecs 35 | outfile = codecs.open('review.txt','w','utf-8') 36 | outfile.write("some text") 37 | outfile.close() 38 | 39 | ____________________________________________________________________________ 40 | 41 | python string operation 42 | -------------------------------------------------------------------------------- /menu.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | def Nilai1(): 4 | nilai = raw_input("Masukkan Nilai Awalnya : ") 5 | nilai = int(nilai) 6 | return nilai 7 | 8 | def Nilai2(): 9 | nilai = raw_input("Masukkan Nilai Akhirnya : ") 10 | nilai = int(nilai) 11 | return nilai 12 | 13 | def Penjumlahan(): 14 | print "Menu Penjumlahan " 15 | hasil = Nilai1()+Nilai2() 16 | return hasil 17 | 18 | def Pengurangan(): 19 | print "Menu Pengurangan " 20 | hasil = Nilai1()-Nilai2() 21 | return hasil 22 | 23 | def Pembagian(): 24 | print "Menu Pembagian " 25 | hasil = Nilai1()/Nilai2() 26 | return hasil 27 | 28 | def Perkalian(): 29 | print "Menu Perkalian " 30 | hasil = Nilai1()*Nilai2() 31 | return hasil 32 | 33 | def Menu(): 34 | print "1. Penjumlahan " 35 | print "2. Pengurangan " 36 | print "3. Pembagian " 37 | print "4. Perkalian " 38 | print 39 | menu = raw_input("Silahkan pilih salah satu menu : ") 40 | menu = int(menu) 41 | if menu == 1: 42 | print 43 | print Penjumlahan() 44 | print 45 | Menu() 46 | elif menu == 2: 47 | print 48 | print Pengurangan() 49 | print 50 | Menu() 51 | elif menu == 3: 52 | print 53 | print Pembagian() 54 | print 55 | Menu() 56 | elif menu == 4: 57 | print 58 | print Perkalian() 59 | print 60 | Menu() 61 | else : 62 | print "Menu belum terdaftar !" 63 | Menu() 64 | 65 | -------------------------------------------------------------------------------- /.ropeproject/config.py: -------------------------------------------------------------------------------- 1 | # The default ``config.py`` 2 | 3 | 4 | def set_prefs(prefs): 5 | """This function is called before opening the project""" 6 | 7 | # Specify which files and folders to ignore in the project. 8 | # Changes to ignored resources are not added to the history and 9 | # VCSs. Also they are not returned in `Project.get_files()`. 10 | # Note that ``?`` and ``*`` match all characters but slashes. 11 | # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc' 12 | # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc' 13 | # '.svn': matches 'pkg/.svn' and all of its children 14 | # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o' 15 | # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o' 16 | prefs['ignored_resources'] = [ 17 | '*.pyc', '*~', '.ropeproject', '.hg', '.svn', '_svn', '.git', 18 | '.tox', '.env', 'node_modules', 'bower_components'] 19 | 20 | # Specifies which files should be considered python files. It is 21 | # useful when you have scripts inside your project. Only files 22 | # ending with ``.py`` are considered to be python files by 23 | # default. 24 | #prefs['python_files'] = ['*.py'] 25 | 26 | # Custom source folders: By default rope searches the project 27 | # for finding source folders (folders that should be searched 28 | # for finding modules). You can add paths to that list. Note 29 | # that rope guesses project source folders correctly most of the 30 | # time; use this if you have any problems. 31 | # The folders should be relative to project root and use '/' for 32 | # separating folders regardless of the platform rope is running on. 33 | # 'src/my_source_folder' for instance. 34 | #prefs.add('source_folders', 'src') 35 | 36 | # You can extend python path for looking up modules 37 | #prefs.add('python_path', '~/python/') 38 | 39 | # Should rope save object information or not. 40 | prefs['save_objectdb'] = True 41 | prefs['compress_objectdb'] = False 42 | 43 | # If `True`, rope analyzes each module when it is being saved. 44 | prefs['automatic_soa'] = True 45 | # The depth of calls to follow in static object analysis 46 | prefs['soa_followed_calls'] = 0 47 | 48 | # If `False` when running modules or unit tests "dynamic object 49 | # analysis" is turned off. This makes them much faster. 50 | prefs['perform_doa'] = True 51 | 52 | # Rope can check the validity of its object DB when running. 53 | prefs['validate_objectdb'] = True 54 | 55 | # How many undos to hold? 56 | prefs['max_history_items'] = 32 57 | 58 | # Shows whether to save history across sessions. 59 | prefs['save_history'] = True 60 | prefs['compress_history'] = False 61 | 62 | # Set the number spaces used for indenting. According to 63 | # :PEP:`8`, it is best to use 4 spaces. Since most of rope's 64 | # unit-tests use 4 spaces it is more reliable, too. 65 | prefs['indent_size'] = 4 66 | 67 | # Builtin and c-extension modules that are allowed to be imported 68 | # and inspected by rope. 69 | prefs['extension_modules'] = [] 70 | 71 | # Add all standard c-extensions to extension_modules list. 72 | prefs['import_dynload_stdmods'] = True 73 | 74 | # If `True` modules with syntax errors are considered to be empty. 75 | # The default value is `False`; When `False` syntax errors raise 76 | # `rope.base.exceptions.ModuleSyntaxError` exception. 77 | prefs['ignore_syntax_errors'] = False 78 | 79 | # If `True`, rope ignores unresolvable imports. Otherwise, they 80 | # appear in the importing namespace. 81 | prefs['ignore_bad_imports'] = False 82 | 83 | # If `True`, rope will transform a comma list of imports into 84 | # multiple separate import statements when organizing 85 | # imports. 86 | prefs['split_imports'] = False 87 | 88 | # If `True`, rope will sort imports alphabetically by module name 89 | # instead of alphabetically by import statement, with from imports 90 | # after normal imports. 91 | prefs['sort_imports_alphabetically'] = False 92 | 93 | 94 | def project_opened(project): 95 | """This function is called after opening the project""" 96 | # Do whatever you like here! 97 | -------------------------------------------------------------------------------- /lirik/.ropeproject/config.py: -------------------------------------------------------------------------------- 1 | # The default ``config.py`` 2 | 3 | 4 | def set_prefs(prefs): 5 | """This function is called before opening the project""" 6 | 7 | # Specify which files and folders to ignore in the project. 8 | # Changes to ignored resources are not added to the history and 9 | # VCSs. Also they are not returned in `Project.get_files()`. 10 | # Note that ``?`` and ``*`` match all characters but slashes. 11 | # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc' 12 | # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc' 13 | # '.svn': matches 'pkg/.svn' and all of its children 14 | # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o' 15 | # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o' 16 | prefs['ignored_resources'] = [ 17 | '*.pyc', '*~', '.ropeproject', '.hg', '.svn', '_svn', '.git', 18 | '.tox', '.env', 'node_modules', 'bower_components'] 19 | 20 | # Specifies which files should be considered python files. It is 21 | # useful when you have scripts inside your project. Only files 22 | # ending with ``.py`` are considered to be python files by 23 | # default. 24 | #prefs['python_files'] = ['*.py'] 25 | 26 | # Custom source folders: By default rope searches the project 27 | # for finding source folders (folders that should be searched 28 | # for finding modules). You can add paths to that list. Note 29 | # that rope guesses project source folders correctly most of the 30 | # time; use this if you have any problems. 31 | # The folders should be relative to project root and use '/' for 32 | # separating folders regardless of the platform rope is running on. 33 | # 'src/my_source_folder' for instance. 34 | #prefs.add('source_folders', 'src') 35 | 36 | # You can extend python path for looking up modules 37 | #prefs.add('python_path', '~/python/') 38 | 39 | # Should rope save object information or not. 40 | prefs['save_objectdb'] = True 41 | prefs['compress_objectdb'] = False 42 | 43 | # If `True`, rope analyzes each module when it is being saved. 44 | prefs['automatic_soa'] = True 45 | # The depth of calls to follow in static object analysis 46 | prefs['soa_followed_calls'] = 0 47 | 48 | # If `False` when running modules or unit tests "dynamic object 49 | # analysis" is turned off. This makes them much faster. 50 | prefs['perform_doa'] = True 51 | 52 | # Rope can check the validity of its object DB when running. 53 | prefs['validate_objectdb'] = True 54 | 55 | # How many undos to hold? 56 | prefs['max_history_items'] = 32 57 | 58 | # Shows whether to save history across sessions. 59 | prefs['save_history'] = True 60 | prefs['compress_history'] = False 61 | 62 | # Set the number spaces used for indenting. According to 63 | # :PEP:`8`, it is best to use 4 spaces. Since most of rope's 64 | # unit-tests use 4 spaces it is more reliable, too. 65 | prefs['indent_size'] = 4 66 | 67 | # Builtin and c-extension modules that are allowed to be imported 68 | # and inspected by rope. 69 | prefs['extension_modules'] = [] 70 | 71 | # Add all standard c-extensions to extension_modules list. 72 | prefs['import_dynload_stdmods'] = True 73 | 74 | # If `True` modules with syntax errors are considered to be empty. 75 | # The default value is `False`; When `False` syntax errors raise 76 | # `rope.base.exceptions.ModuleSyntaxError` exception. 77 | prefs['ignore_syntax_errors'] = False 78 | 79 | # If `True`, rope ignores unresolvable imports. Otherwise, they 80 | # appear in the importing namespace. 81 | prefs['ignore_bad_imports'] = False 82 | 83 | # If `True`, rope will transform a comma list of imports into 84 | # multiple separate import statements when organizing 85 | # imports. 86 | prefs['split_imports'] = False 87 | 88 | # If `True`, rope will sort imports alphabetically by module name 89 | # instead of alphabetically by import statement, with from imports 90 | # after normal imports. 91 | prefs['sort_imports_alphabetically'] = False 92 | 93 | 94 | def project_opened(project): 95 | """This function is called after opening the project""" 96 | # Do whatever you like here! 97 | --------------------------------------------------------------------------------