[Tutor] Using Python to solve factoria
Hello, I really happy to be accepted to the list! This is my current function: def factoria(numb): While numb > 1: If numb==0: return 1 Else: result = numb*(numb-1) numb = numb -1 return result factoria(5) #should output 120 What am I not getting right? Thanks Heddy Sent from my iPhone > On 21 Dec 2016, at 01:17, tutor-requ...@python.org wrote: > > Welcome to the Tutor@python.org mailing list! This list is for folks > who want to ask (and/or answer) questions from folks who wish to learn > how to program with Python. Feel free to ask even the most basic of > questions -- that's what the list is for! > > For best results when asking a question on this list: - Try to write > some code to solve your problem - Show the code you have written - > Describe what the code does and what you want it to do - If the code > generates an error, copy and paste the entire error message, including > the traceback, into your email. - Tell us what OS and Python version > you are using. > > - Don't ask us to do your homework. - Don't assume we know what you > are talking about. If you are having trouble with a third-party > library, include a link to the library home page. > > When replying to a posting: - Use Reply All to reply to the entire > list - Don't top post - put your reply after the text to which you are > replying > > For all posts: - Format your email as plain text, not HTML > > > To post to this list, send your message to: > > tutor@python.org > > General information about the mailing list is at: > > https://mail.python.org/mailman/listinfo/tutor > > If you ever want to unsubscribe or change your options (eg, switch to > or from digest mode, change your password, etc.), visit your > subscription page at: > > > https://mail.python.org/mailman/options/tutor/ajakzhedgar%2Bnewsletter%40gmail.com > > > You can also make such adjustments via email by sending a message to: > > tutor-requ...@python.org > > with the word `help' in the subject or body (don't include the > quotes), and you will get back a message with instructions. > > You must know your password to change your options (including changing > the password, itself) or to unsubscribe without confirmation. It is: > > analyst > > Normally, Mailman will remind you of your python.org mailing list > passwords once every month, although you can disable this if you > prefer. This reminder will also include instructions on how to > unsubscribe or change your account options. There is also a button on > your options page that will email your current password to you. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trouble Launching Python
2016-12-19 23:38 GMT+01:00 Joseph Olugbohunmi via Tutor : > Hello,Good day, I installed Python 3.5.2 on my Windows 8.1 PC and then I > tried launching IDLE as well as the Interpreter but I got a message that > api-ms-win-crt-runtime-l1-1-0.dll was missing. I downloaded and installed > that after which I got another message that > api-ms-win-crt-math-l1-1-0.dll was also missing, I got that, and then > another dll was missing and it goes on and on. Please what can I > do?ThanksJoseph > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > Hi Joseph, this is a Microsoft visual c++ redistributable is missing from system. I found this stackoverflow link which seems to describing a solution http://stackoverflow.com/questions/33265663/api-ms-win-crt-runtime-l1-1-0-dll-is-missing-when-opening-microsoft-office-file BR, George ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Question about selenium with python
Hello, Im a new programmer and this is my first time posting here. I have a question about using selenium with python. My first question is how do I get selenium to click on a link contained within a specific cell of a table? I know how to get selenium to click on a link in general but in this case there are several links which have the same name, but each of these links are in a different cell. Basically Id like to give selenium the location of a specific cell, and then tell it to click on the link inside that cell. Lets say the link is located in the 3nd row and 3nd column of a table. I tried the following code but it didnt work link = driver.find_element_by_xpath("//tr[3]/td[3]") link.click() Thanks Fuzz heres an example of the HTML code im working with: Name Clinic # Name1 MRN1 Plans | Delete ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Using Python to solve factoria
Welcome! On Wed, Dec 21, 2016 at 1:50 AM, Hedgar wrote: > Hello, > > I really happy to be accepted to the list! > This is my current function: > > def factoria(numb): > While numb > 1: > If numb==0: > return 1 > Else: > result = numb*(numb-1) > numb = numb -1 > return result > factoria(5) > #should output 120 > What am I not getting right? I'll help you part way. Firstly Python is case sensitive. You have several examples of where you start Python keywords with a capital letter when it should be lowercase. Secondly Python uses indentation (Conventionally 4 spaces.) to segregate code blocks. Thirdly, you won't see the result of your function if you don't print it. So if I correct these in your code I get: def factoria(numb): while numb > 1: if numb==0: return 1 else: result = numb*(numb-1) numb = numb -1 return result print(factoria(5)) But alas! There is more work to be done. This will not give you a syntax error, but now there is an issue with logic error(s). Can you figure it out? It might help if you pretend you are the computer and work out the while loop on paper through each iteration until it exits. Also, when you ask for help you should copy and paste the full traceback of the error you received. What did you get? Did the error relate to anything I corrected above? Unfortunately you won't get a traceback for logic errors! Also give the version of Python and your operating system. I am assuming you are using Python 3. HTH! boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trouble Launching Python
On Tue, Dec 20, 2016 at 7:12 PM, George Fischhof wrote: > 2016-12-19 23:38 GMT+01:00 Joseph Olugbohunmi via Tutor : > > this is a Microsoft visual c++ redistributable is missing from system. > I found this stackoverflow link which seems to describing a solution > > http://stackoverflow.com/questions/33265663/ > api-ms-win-crt-runtime-l1-1-0-dll-is-missing-when-opening-microsoft-office-file There is no reason in this case to install the VC++ redistributable package. Python is written in C, so it only needs the C runtime, which is now an OS component. I provided a link for the updated download for the Universal C Runtime, KB3118401. The above Stack Overflow answer mentions KB2999226, which is the old, outdated update from well over a year ago. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Open a libreoffice calc file in Python
Python 3.4 on Ubuntu If I was going to open a libreoffice calc file from the terminal I would go: libreoffice --calc /home/path/to/myfile.ods. How would I do this from Python? Thanks, Jim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Open a libreoffice calc file in Python
On Wed, Dec 21, 2016 at 9:37 PM, Jim Byrnes wrote: > Python 3.4 on Ubuntu > > If I was going to open a libreoffice calc file from the terminal I would go: > libreoffice --calc /home/path/to/myfile.ods. > > How would I do this from Python? My first thought was: import os os.system(insert_your_command) But looking at the documentation (https://docs.python.org/3/library/os.html#os.system) it says it is preferable to use the subprocess module with documentation here: https://docs.python.org/3/library/subprocess.html#replacing-os-system It makes me wonder if I should go back and revisit some code I wrote as I used the os.system()approach. But was this option available in Py 2.4.4? I'll have to check. -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Open a libreoffice calc file in Python
On 21Dec2016 21:54, boB Stepp wrote: On Wed, Dec 21, 2016 at 9:37 PM, Jim Byrnes wrote: Python 3.4 on Ubuntu If I was going to open a libreoffice calc file from the terminal I would go: libreoffice --calc /home/path/to/myfile.ods. How would I do this from Python? My first thought was: import os os.system(insert_your_command) But looking at the documentation (https://docs.python.org/3/library/os.html#os.system) it says it is preferable to use the subprocess module with documentation here: https://docs.python.org/3/library/subprocess.html#replacing-os-system It makes me wonder if I should go back and revisit some code I wrote as I used the os.system()approach. But was this option available in Py 2.4.4? I'll have to check. Subprocess arrived with Python 2.4, so you should be fine. To my mind the more important thing is to use the "shell=False" version of Popen. os.system() inherently accepts a shell command string, which means you need to hand quote the /home/path/to/myfile.ods. But it is better to pass an array of strings: ['libreoffice', '--calc', path_value] where path_value is a Python variable containing "/home/path/to/myfile.ods" or whatever the path is. This way you don't need to do anything special for, um, "unusual" paths because you're not passing the string _through_ the shell. BTW, the array form is Popen's default mode; sensibly you need to _ask_ to use a shell string with shell=True, because that is harder and more fragile. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Open a libreoffice calc file in Python
On Thu, Dec 22, 2016 at 4:50 AM, wrote: > BTW, the array form is Popen's default mode; sensibly you need to _ask_ to > use a shell string with shell=True, because that is harder and more fragile. Without shell=True, args as a string on POSIX is generally an error because it will look for the entire string as the executable. The exception is if the string has no command-line arguments (e.g. Popen('ls')). On Windows it's always acceptable to pass args as a string. For a complex command line it may be easier to pass args as a list and let Popen call list2cmdline to create a string that's properly quoted and escaped. Here 'properly' assumes the target executable parses its command line using VC++ rules. It may use custom rules, in which case you have to pass args as a string. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor