[no subject]
I subscribed to python list and now I want to state my requeat.I downloaded Python because I wanted to learn how to code.I also downloaded a text editor specially designed for coding Python(which iscalled Pycharm) .both of the softwares and my Windows 10 software was he latest.I got into Python and it asked me which text file I was going to use to edit files,but the app(which is Python)couldn't find where the files were located.Hope I shall get a reply sir Thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re:
On Dec 11, 2018 3:05 PM, "Alperen Eroğlu" <33alperen200...@gmail.com> wrote: > > I subscribed to python list and now I want to state my requeat.I downloaded > Python because I wanted to learn how to code.I also downloaded a text > editor specially designed for coding Python(which iscalled Pycharm) > .both of the softwares and my Windows 10 software was he latest.I got into > Python We will need more information in order to help you. What did you do to get into python? and it asked me which text file I was going to use to edit files I'm sorry but that does not make sense to me. Could you show us exactly what this request looks like? > the app(which is Python)couldn't find where the files were located. Again please show us the messages you got. It is best if possible to copy and paste this information into your reply Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
03 digression by brute force
SYNOPSIS: One way to solve math puzzle by brute force. (message sent earlier disappeared) Quick note. Jack started by asking why python does not like decimal numbers with leading zeroes. When asked to explain, he said he was trying to solve word problems using python. Someone mentioned problems like solving SEND + MORE = MONEY and I decided to quickly write a function that would solve anything of that sort that only has addition on either side of the equals. What amused me was that I had 25 solutions to the above when I was told there would be one. Closer examination showed that 24 of those had the ‘M’ in MONEY set to zero which the logicians claimed was not a sensible solution. This solution is one of a list of 25 dictionaries returned, printed with pprint.print: {' SYNOPSIS': 'PUZZLE: SEND+MORE=MONEY with SOLUTION #1: 7429+0814=08243', 'D': '9', 'E': '4', 'M': '0', 'N': '2', 'O': '8', 'R': '1', 'S': '7', 'Y': '3'} Note M == 0 The lone normal answer is: {' SYNOPSIS': 'PUZZLE: SEND+MORE=MONEY with SOLUTION #25: 9567+1085=10652', 'D': '7', 'E': '5', 'M': '1', 'N': '6', 'O': '0', 'R': '8', 'S': '9', 'Y': '2'} Apparently, unless you tell the program to skip any attempts where M is not 1, it finds these. I will spare the rest but include the code if you wish to try it. I called the function this (perhaps odd) way: puzzle = "SeND+ MoRe =MoNeY???" solution25 = math_word_puzzle_solver(puzzle) And it returned a list of the 25 dicts. So I tried this puzzle: puzzle = "SeND + MoRe = oNeY" I guessed (wrongly) that by removing the offending M in MONEY, it would find only the other 24 solutions with the M in MORE being 0. Not quite. That got 108 solutions! M was just about anything: [d['M'] for d in solution108 ] ['6', '2', '5', '3', '6', '2', '5', '3', '7', '1', '6', '2', '7', '6', '2', '1', '5', '3', '7', '1', '5', '2', '5', '2', '7', '0', '7', '0', '4', '3', '7', '0', '8', '0', '4', '3', '8', '0', '8', '0', '6', '2', '5', '1', '6', '0', '5', '1', '6', '0', '5', '1', '7', '0', '4', '3', '7', '0', '7', '6', '1', '0', '7', '0', '4', '1', '5', '0', '6', '4', '2', '0', '6', '0', '6', '0', '3', '1', '5', '0', '5', '0', '3', '2', '2', '1', '2', '1', '2', '1', '3', '0', '2', '1', '3', '0', '3', '1', '2', '0', '2', '0', '3', '0', '3', '0', '2', '1'] My main point though is that a leading zero can appear including in bank account numbers, social security numbers and so on. But I accept that historically python is as it is. As I mentioned, some functions like int() can deal with them. I attach my code in case anyone is interested in seeing the whole output or trying it on other puzzles. The code uses no exec() or eval() and should be safe 😊 CODE # Module created to solve a specific kind of math word problem. # FIND all solutions to a puzzle by systematically # replacing LETTERS with NUMERALS till an equation is True # Accepts string like "SEND + MORE = MONEY" # Measure time elapsed, optional: def math_word_puzzle_solver(puzzle): """USAGE: math_word_puzzle_solver(puzzle)""" """Solve a puzzle by brute force""" """of the form SEND + MORE = MONEY""" """with arbitrary sums on either side of""" """the equation.""" # NOTE: comments illustrate what happens to the test case only. # Assuming the user typed in garbage, will restrict characters and normalize. # Remove whitespace and most other things except +/=, make uppercase, etc. puzzle = puzzle.upper() retain = set('ABCDEFGHIJKLMNOPQRSTUVWXYZ=+') puzzle = ''.join(filter(retain.__contains__, puzzle)) # puzzle := 'SEND+MORE=money' # Split into left/right on the equals sign: left_text, right_text = puzzle.split('=') # left_text := 'SEND+MORE' # right_text := 'MONEY' (or 'ONEY') # Split each side into a list on "+" and in the test case # only the left side has more than one: left_list = left_text.split('+') right_list = right_text.split('+') # At this point we have: # left_list: ['SEND', 'MORE'] # right_list: ['MONEY'] # Combine everything in both lists to make a set with unique letters. letter_set = { letter for word in (left_list + right_list) for letter in word } # Letter_set := {'M', 'O', 'R', 'Y', 'N', 'S', 'E', 'D'} letter_count = len(letter_set) # letter_count := 8 # Make an iterator to deliver one combination at a time # of the n-tuple of n digits at a time from 0-9 with no replacement # and luckily that problem is solved by using the itertools module: import itertools # We want all permutations taken letter_count at a time # so the iterator will return an 8-tuple in this example looking like: #('0'
[RELEASE] Python 3.7.2rc1 and 3.6.8rc1 now available for testing
https://blog.python.org/2018/12/python-372rc1-and-368rc1-now-available.html Python 3.7.2rc1 and 3.6.8rc1 are now available. 3.7.2rc1 is the release preview of the next maintenance release of Python 3.7, the latest feature release of Python. 3.6.8rc1 is the release preview of the next and last maintenance release of Python 3.6, the previous feature release of Python. Assuming no critical problems are found prior to 2018-12-20, no code changes are planned between these release candidates and the final releases. These release candidates are intended to give you the opportunity to test the new security and bug fixes in 3.7.2 and 3.6.8. We strongly encourage you to test your projects and report issues found to bugs.python.org as soon as possible. Please keep in mind that these are preview releases and, thus, their use is not recommended for production environments. You can find these releases and more information here: https://www.python.org/downloads/release/python-372rc1/ https://www.python.org/downloads/release/python-368rc1/ -- Ned Deily n...@python.org -- [] -- https://mail.python.org/mailman/listinfo/python-list
Re: 03 digression by brute force
On 2018-12-12 02:06, Avi Gross wrote: [snip] My main point though is that a leading zero can appear including in bank account numbers, social security numbers and so on. But I accept that historically python is as it is. As I mentioned, some functions like int() can deal with them. Bank account numbers, etc, are not really numbers, but are, instead, identifiers. You wouldn't do arithmetic with such a number, nor should you store one in a integer field in a database. Dropping a leading digit would be like dropping a leading letter of a name. -- https://mail.python.org/mailman/listinfo/python-list
Re: 03 digression by brute force
"Avi Gross" writes: > SYNOPSIS: One way to solve math puzzle by brute force. (message sent earlier > disappeared) > > > > Quick note. Jack started by asking why python does not like decimal > numbers with leading zeroes. When asked to explain, he said he was > trying to solve word problems using python. Someone mentioned problems > like solving SEND + MORE = MONEY and I decided to quickly write a > function that would solve anything of that sort that only has addition > on either side of the equals. > > > > What amused me was that I had 25 solutions to the above when I was > told there would be one. Closer examination showed that 24 of those > had the ‘M’ in MONEY set to zero which the logicians claimed was not a > sensible solution. What amuses me is the solution to the problem that started the whole thread had at least one number with a leading 0. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to test for type or instance of dict_values?
Very late to the party, but I just encountered a very similar problem and found a solution: ``` import collections obj = {"foo": "bar"} isinstance(obj.values(), collections.abc.ValuesView) # => True ``` Hope that helps someone out there :) On Thursday, November 17, 2016 at 9:09:23 AM UTC-8, Terry Reedy wrote: > On 11/17/2016 9:57 AM, Thorsten Kampe wrote: > > > The code in question is part of an attempt to get the dimensions of > > multi-dimensional lists, the `isinstance` is there in order to > > exclude strings. > > You can do the exclusion directly. > > > > > """ > > def dim(seq): > > dimension = [] > > while isinstance(seq, (list, tuple)): > > while not isinstance(seq, str) # or (str, bytes, ...) > > > dimension.append(len(seq)) > > try: > > seq = seq[0] > > except IndexError: # sequence is empty > > break > > return dimension > > """ > > > > Thorsten > > > > > -- > Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
zeroed out
Joe, All numbers start with zero, and even an infinite number of them! LOL! All kidding aside, I note that some data that is stored in a fixed width has zeroes padding it all the way to the right. If you store the number 3 in binary as a byte, it tends to look like 0011. Depending on how integers are stored, something similar can happen for longer stretches. But with decimals, we tend to not bother showing the empty areas that represent 0 times ever higher powers of 10. But on the right, zeroes are required as otherwise you have no idea what the other numerals mean. 5900 is not 59. Yes, you can write 59e2 or 5.9e3. Yet on the other side of the decimal point, it is reversed. You need 0's on the left but on the right only if you want to show significance. But there are limits. Most programs do not support indefinite precision arithmetic. Too many digits including zeroies tend to be ignored. Python integers though, see boundless: >>> 2**80 1208925819614629174706176 >>> _**10 666801443287985427407985179072125779714475832231590816039625781176403723781763207152143220087155429074292991059343324044501654119365080363356052330830046095157579514014558463078285911814024728965016135886601981690748037476461291163877376 >>> _**10 1737662031938094565999824459494356270619397861001172505471732865032623760224580084650943336301208543380031943621630075979872254724835986408433356854417101939662741313385571925863990067892927145547675001947961279645969066059766058736658595806001619985565113685309604009071992534506041686227703502285271246267285386268054188334701076510916419199007254159946899201122191709070235613544840470257137346516087775445798461110010594821321809566894441083157854016421880441787886298535922284673317305198107635595779448820162864939086315031011211661095716822957694703795145311052399652092453140826655185793355112915252303733164866977865323352062741492408134892018287738543530418555987093906754309603810722704323839135427021302024301866373218623310688617767802110828569845060500248953943201394358684846438433680024960899560464199640198775868455302077489943945015055881469790826298713660881217637905553645132439842440041476360402191364434103777980116087227171313236217001593357864456019476016940251078882930170581785626471754610263843434388748614065167671583732790323210962621265516202550518578946320794439190575688682966752055301472437224530087878609170056344407910709900900338023035646198926037727398602328144407608278340682447170349984464291558779014638475805166354777533602182917103341104379697704219051965786176280422614748075085278062866268677842432851421790544407006581148631979148571299417963950579210719961422405768071335213324842709316205032078384168750091017964584060285240107161561019930505687950233196051962261970932008838279760834318101044311710769457048672103958655016388894770892065267451228938951370237422841366052736174160431593023473217066764172949768821843606479073866252864377064398085101223216558344281956767163876579889759124956035672317578122141070933058555310274598884089982879647974020264495921703064439532898207943134374576254840272047075633856749514044298135927611328433323640657533550512376900773273703275329924651465759145114579174356770593439987135755889403613364529029604049868233807295134382284730745937309910703657676103447124097631074153287120040247837143656624045055614076111832245239612708339272798262887437416818440064925049838443370805645609424314780108030016683461562597569371539974003402697903023830108053034645133078208043917492087248958344081026378788915528519967248989338592027124423914083391771884524464968645052058218151010508471258285907685355807229880747677634789376 -Original Message- From: Python-list On Behalf Of Joe Pfeiffer Sent: Wednesday, December 12, 2018 12:04 AM To: python-list@python.org Subject: Re: 03 digression by brute force "Avi Gross" writes: > SYNOPSIS: One way to solve math puzzle by brute force. (message sent > earlier disappeared) > > > > Quick note. Jack started by asking why python does not like decimal > numbers with leading zeroes. When asked to explain, he said he was > trying to solve word problems using python. Someone mentioned problems > like solving SEND + MORE = MONEY and I decided to quickly write a > function that would solve anything of that sort that only has addition > on either side of the equals. > > > > What amused me was that I had 25 solutions to the above when I was > told there would be one. Closer examination showed that 24 of those > had the ‘M’ in MONEY set to zero which the logicians claimed was not a > sensible solution. What amuses me is the solution to the problem that started the whole thread had at least one number with a leading 0. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list