Re: [Tutor] Hi there,
On Sat, Jan 02, 2016 at 02:45:30PM +0200, yehudak . wrote: > I'm trying to write a Python 3.5 program to find how many trailing zeros > are in 100! (factorial of 100). > I downloaded factorial from Math module, but all my efforts to solve the > problem failed. > > I know the mathematical way to solve it (resulting in 24), but I want a > Python solution. Here are the steps needed: http://www.purplemath.com/modules/factzero.htm Try writing some Python code for this, and if you have trouble, show us your code and we'll help. But you have to write it first -- we won't do your homework for you. -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hi there,
On 02/01/16 12:45, yehudak . wrote: > I know the mathematical way to solve it (resulting in 24), but I want a > Python solution. Show us your code. Usually "the mathematical way to do it" works in Python too. Although there will likely be other ways that may sometimes run faster or easier to code. But until we see your code we can't comment on what you are doing. One way to try would be continually dividing by 10 until you get a non-zero remainder. Count the number of divisions necessary. Hint: The divmod() function may help here. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Difference between rounding off and typecasting to int
On 02/01/16 14:33, Ratheesh kumar wrote: > But I can't get to understand what round() did int() cant't do With this kind of question its best to ask the interpreter: >>> int(12.1) 12 >>> int(12.9) 12 >>> round(12.1) 12 >>> round(12.9) 13 >>> Does that make it clearer? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Difference between rounding off and typecasting to int
Hii everyone, Today i was just solving a problem in hacker-rank. A simple one to calculate the tip and tax for the meal. The resultant answer should be rounded off. I first wrote the code as below: m=float(input()) x=int(input()) t=int(input()) tip=(m*x)/100 tax=(m*t)/100 total=m+tip+tax print("The final price of the meal is $",end='') print(int(total),end='') print('.') It passed three test-cases but the last test continued to fail. Then i came to know that the problem was with rounding off. Then i edited my code to the following: m=float(input()) x=int(input()) t=int(input()) tip=(m*x)/100 tax=(m*t)/100 total=m+tip+tax print("The final price of the meal is $",end='') print(round(total),end='') print('.')Finally all test-cases passed. But I can't get to understand what round() did int() cant't do to the variable total. Can anyone pinpoint the change. Thank you. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Hi there,
I'm trying to write a Python 3.5 program to find how many trailing zeros are in 100! (factorial of 100). I downloaded factorial from Math module, but all my efforts to solve the problem failed. I know the mathematical way to solve it (resulting in 24), but I want a Python solution. Thank you. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] trouble with beautiful soup
-Ursprüngliche Nachricht- Von: Danny Yoo [mailto:d...@hashcollision.org] Gesendet: Freitag, 1. Januar 2016 19:17 An: Alan Gauld Cc: marcus lütolf ; Python Tutor Mailing List Betreff: Re: [Tutor] trouble with beautiful soup According to the documentation for Beautiful Soup 3, http://www.crummy.com/software/BeautifulSoup/bs3/documentation.html you must use one of the following: from BeautifulSoup import BeautifulSoup # For processing HTML OR from BeautifulSoup import BeautifulStoneSoup # For processing XML OR import BeautifulSoup # To get everything Note that capitalization matters. Yes !!! Thank you all again, case closed, Marcus. --- Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. https://www.avast.com/antivirus ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] antigravity?!?
On Sat, Jan 02, 2016 at 12:46:01AM -0600, boB Stepp wrote: > Ok, you Python developers (If any follow the Tutor list.) are a quirky > lot! Thinking about Martin's suggestion to explore the standard > library, I typed "py" in my W7 Command Prompt, followed by "help()" > and then modules to see what modules I had installed on my system. > While doing so, I was intrigued by one called, "antigravity". Hmm. > So I next typed "antigravity" to see what this thing was. I was > immediately startled! My Chrome browser, open next to the Command > Prompt window, suddenly went to the xkcd web site! Huh? Well, that > comic explains "antigravity". But it does not explain the rest of the > help entry: Geohashing is explained by one of the other XKCD cartoons. You'll need to google for it, I don't remember what it does. [...] > What else awaits as I explore Python??? antigravity is an Easter Egg. You can also try: import this from __future__ import braces from __future__ import barry_as_FLUFL (the last one is *very* subtle, it might take you a while to work out what it does). There may be a few others, I don't remember. -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What potential problems might I encounter installing Anaconda?
On 02/01/16 04:26, boB Stepp wrote: > 1) At this time I have no need for multiple versions of Python on my > home PC. Would it be advisable for me to uninstall my existing v. > 3.4.4 as the Anaconda distribution I am looking at uses v. 3.5? It shouldn';t make any difference. Anaconda and v3.4 can coexist. But removing the older distro should be fine too, it just makes anaconda your default for all Python scripts. > 2) Will installing Anaconda cause any problems with my existing Vim > 7.4 installation? No. > any Python-related plugins in Vim. However, I do value the existing > syntax highlighting Vim does for Python out of the box. The syntax highlighting is not powered by Python, its simply a bunch of regex patterns. Depending on your vim there may be a Python interpreter to execute Python macros but I believe that's implemented as a library inside Vim it does not use the system interpreter. So even if you deleted all Pythons from your PC vim would not be impacted. > to reinstall Vim after installing Anaconda for Vim to be able to find > Python? No. > 3) Is there anything else I need to be aware of regarding Anaconda? > 4) ...that updates and new Python package installations are > done in Anaconda with a "conda" command. Does this mean that pip > installations can no longer be done? Sorry I can't answer that, you'll need an Anaconda user I guess. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor