-
-
Save techsoft29/0b5c65abb4ba5d97e953109de27749e6 to your computer and use it in GitHub Desktop.
Revisions
-
Ernesto Lowy revised this gist
Sep 21, 2021 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4112,4 +4112,12 @@ def is_tool(name): # from whichcraft import which from shutil import which return which(name) is not None // % modulo operator a = 9 b = 3 answer = a % b print(answer) -
Ernesto Lowy revised this gist
Sep 14, 2021 . 1 changed file with 0 additions and 39 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,39 +0,0 @@ -
Ernesto Lowy revised this gist
Sep 14, 2021 . 1 changed file with 0 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +0,0 @@ -
Ernesto Lowy revised this gist
Sep 14, 2021 . 1 changed file with 0 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +0,0 @@ -
Ernesto Lowy revised this gist
Sep 14, 2021 . 1 changed file with 0 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +0,0 @@ -
Ernesto Lowy revised this gist
Sep 14, 2021 . 1 changed file with 0 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,10 +5,3 @@ # how to make a function to return multiple values, Read article on: https://note.nkmk.me/en/python-function-return-multiple-values/ -
Ernesto Lowy revised this gist
Sep 13, 2021 . 1 changed file with 0 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,13 @@ # Exercises extracted from : # https://github.com/zhiwehu/Python-programming-exercises/blob/master/100%2B%20Python%20challenging%20programming%20exercises%20for%20Python%203.md # print the intersection of the 2 lists set1=set([1,3,6,78,35,55]) set2=set([12,24,35,24,88,120,155]) set1 &= set2 li=list(set1) print(li) # write assert statements to verify that every number in the list [2,4,6,8] is even. li = [2,4,6,8] for i in li: -
Ernesto Lowy revised this gist
Sep 13, 2021 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2540,6 +2540,12 @@ assert not isinstance(lst, str) #In Python2 assert not isinstance(lst, basestring) // # Check if something is either a float or int a='s' if not isinstance(a, (int, float)): print("a is either int or float") // #checking if something is a list: if not isinstance(objs,list): print "h" -
Ernesto Lowy revised this gist
May 20, 2021 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ # Python program to explain shutil.which() method # check if python is in PATH # importing os module import os # importing shutil module import shutil # cmd cmd = 'python' # Using shutil.which() method locate = shutil.which(cmd) # Print result print(locate) # outputs: /usr/bin/python -
Ernesto Lowy revised this gist
Apr 12, 2021 . 1 changed file with 0 additions and 46 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -226,52 +226,6 @@ Find Key, Values Pairs In Common # Find countries where the amount of exports matches the amount of imports importers.items() & exporters.items() {('Spain', 252)} // # Merge 2 dictionaries (dicts) >>> x = {'a': 1, 'b': 2} -
Ernesto Lowy revised this gist
Mar 11, 2021 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ # Integer division a = 1 b = 2 int_div = a // b print(int_div) # will print 0 -
Ernesto Lowy revised this gist
Mar 6, 2021 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,11 @@ print("Created: %s" % time.ctime(os.path.getctime("test.py"))) # how to make a function to return multiple values, Read article on: https://note.nkmk.me/en/python-function-return-multiple-values/ # enter an int from command line size = int(input()) # enter a list of numbers from command line numbers = list(map(int, input().split())) print(numbers) -
Ernesto Lowy revised this gist
Feb 1, 2021 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ ## Pickle to serialize an object (for example a dictionary): # Dump first: import pickle example_dict = {1:"6",2:"2",3:"f"} pickle_out = open("dict.pickle","wb") pickle.dump(example_dict, pickle_out) pickle_out.close() #Now, you can load: pickle_in = open("dict.pickle","rb") example_dict = pickle.load(pickle_in) -
Ernesto Lowy revised this gist
Dec 16, 2020 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ # get creation and last modification time of a file or directory import os.path, time print("Last modified: %s" % time.ctime(os.path.getmtime("test.py"))) print("Created: %s" % time.ctime(os.path.getctime("test.py"))) # how to make a function to return multiple values, Read article on: https://note.nkmk.me/en/python-function-return-multiple-values/ -
Ernesto Lowy revised this gist
Dec 15, 2020 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ # get creation and last modification time of a file or directory import os.path, time print("Last modified: %s" % time.ctime(os.path.getmtime("test.py"))) print("Created: %s" % time.ctime(os.path.getctime("test.py"))) -
Ernesto Lowy revised this gist
Dec 14, 2020 . 1 changed file with 21 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,3 +27,24 @@ for i in li: # Use u'strings' format to define unicode string. unicodeString = u"hello world!" print(unicodeString) # Assuming that we have some email addresses in the "[email protected]" format, please write program to print the user name of a given email address. Both user names and company names are composed of letters only. Example: If the following email address is given as input to the program: [email protected] Then, the output of the program should be: john In case of input data being supplied to the question, it should be assumed to be a console input. Hints: Use \w to match letters. import re emailAddress = raw_input() pat2 = "(\w+)@((\w+\.)+(com))" r2 = re.match(pat2,emailAddress) print(r2.group(1)) -
Ernesto Lowy revised this gist
Dec 14, 2020 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,3 +23,7 @@ print(li) li = [2,4,6,8] for i in li: assert i%2==0 # Use u'strings' format to define unicode string. unicodeString = u"hello world!" print(unicodeString) -
Ernesto Lowy revised this gist
Dec 14, 2020 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,4 +17,9 @@ print(li) # list comprehension for removing a certain element of a list li = [12,24,35,24,88,120,155] li = [x for x in li if x!=24] print(li) # write assert statements to verify that every number in the list [2,4,6,8] is even. li = [2,4,6,8] for i in li: assert i%2==0 -
Ernesto Lowy revised this gist
Dec 11, 2020 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,4 +12,9 @@ set1=set([1,3,6,78,35,55]) set2=set([12,24,35,24,88,120,155]) set1 &= set2 li=list(set1) print(li) # list comprehension for removing a certain element of a list li = [12,24,35,24,88,120,155] li = [x for x in li if x!=24] print(li) -
Ernesto Lowy revised this gist
Dec 11, 2020 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,11 @@ $ s=['a','b','c','d'] $ s = s[::-1] $ print(s) ['d', 'c', 'b', 'a'] # print the intersection of the 2 lists set1=set([1,3,6,78,35,55]) set2=set([12,24,35,24,88,120,155]) set1 &= set2 li=list(set1) print(li) -
Ernesto Lowy revised this gist
Dec 11, 2020 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # Exercises extracted from : # https://github.com/zhiwehu/Python-programming-exercises/blob/master/100%2B%20Python%20challenging%20programming%20exercises%20for%20Python%203.md # iterate a list in the reverse order: $ s=['a','b','c','d'] $ s = s[::-1] $ print(s) ['d', 'c', 'b', 'a'] -
Ernesto Lowy revised this gist
Dec 11, 2020 . No changes.There are no files selected for viewing
-
Ernesto Lowy renamed this gist
Oct 8, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ https://www.python.org/dev/peps/pep-0008/ *Class Names: Class names should normally use the CapWords convention *Funcƒtion Names; Function names should be lowercase, with words separated by underscores as necessary to improve readability. -
Ernesto Lowy revised this gist
Oct 8, 2020 . No changes.There are no files selected for viewing
-
Ernesto Lowy revised this gist
May 26, 2020 . No changes.There are no files selected for viewing
-
Ernesto Lowy revised this gist
May 26, 2020 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4145,4 +4145,11 @@ chunks = re.split(' +', str) print(chunks) // # Testing if a binary exists def is_tool(name): """Check whether `name` is on PATH and marked as executable.""" # from whichcraft import which from shutil import which return which(name) is not None -
Ernesto Lowy revised this gist
May 26, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4145,4 +4145,4 @@ chunks = re.split(' +', str) print(chunks) // # Testing if a binary exists -
Ernesto Lowy revised this gist
May 26, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4144,3 +4144,5 @@ chunks = re.split(' +', str) print(chunks) // # Tes -
Ernesto Lowy revised this gist
May 26, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4143,3 +4143,4 @@ str = '63 41 92 81 69 70' chunks = re.split(' +', str) print(chunks) -
Ernesto Lowy revised this gist
May 26, 2020 . No changes.There are no files selected for viewing
NewerOlder