4,305 Posted Topics
Re: To preserve your proper indentation check http://www.daniweb.com/community/syntax under code blocks. | |
Re: Looks like you have a series of hang images in an external folder. Prefix the image names with the full path to this folder. By the way, you can use the foreward slash '/' with Windows, this way you can avoid a raw string designation. | |
Re: Hint ... text = 'Houseboat' text = text.lower() text_rev = text[::-1] print(text) print(text_rev) print('-'*20) text = 'Racecar' text = text.lower() text_rev = text[::-1] print(text) print(text_rev) | |
Re: See ... http://www.daniweb.com/software-development/python/threads/466346/word-jumble#post2031135 | |
Re: Hint ... ''' word_scramble_hint101.py create a scrambled/jumbled word that has a hint associated with it ''' import random # a list of (word, hint) tuples word_hint = [ ('mouse', 'eats cheese'), ('automobile', 'uses petrol'), ('boat', 'floats on water') ] # shuffle word_hint list in place and pick a random word … | |
Re: Your snippet works well using ... SnippetCompiler.exe from: http://www.sliver.com/dotnet/SnippetCompiler/ I had to run this in IronPython, here is the code ... ''' ip_small_form101.py using IronPython from http://www.codeplex.com/ironpython ''' import clr clr.AddReference('System.Windows.Forms') import System.Windows.Forms as swf class Class1(swf.Form): def __init__(self): label = swf.Label() label.Text = "Hello world!" self.Controls.Add(label) form = Class1() … | |
Re: A lot of us have programmed in wxPython, so let us see what you got. | |
Re: Even if you have your own business, you will be working for your clients/customers and the government's rules. No, you cannot wear what you want. | |
Just another loan calculation, this time using a handy function in Python module numpy. | |
| |
Starting with Python 3.3 you now have access to a high resolution time counter (nanoseconds and better). | |
Re: I am thinking about buying the new mac air. Many thanks for the info. | |
Re: Tuples, since they are immutable (can not be changed), are also useful for keys in a dictionary. | |
Re: Try this ... ''' wants "MATHEICS" not "ACEIHMST" ''' s = "Mathematics".upper() s3 = "" for c in s: if c not in s3: s3 += c print(s3) # MATHEICS | |
![]() | Re: Here you go ...  |
Re: Also tell us which version of Python you are using (Python2 or Python3) | |
Re: Here is a hint on the turtle goto(x, y) ... ''' turtle_star_six.py draw a star with six points using Python module turtle ''' import turtle as tu def draw_star(x, y, side): star_angle = 360.0/6 left_angle = star_angle * 2 tu.penup() # start drawing here (default is center x=0, y=0) tu.goto(x, … | |
Python module turtle makes it simple to draw graphics art similar to art done by the Logo language. | |
Using Python module turtle to draw a Koch snow fractal. | |
Re: The code below should work if Qbasic works at all like BCX: dim inner, outer FOR outer = 1 to 5 FOR inner = 1 to outer PRINT CHR$(inner + 64); ' stay on line NEXT innner PRINT ' new line feed NEXT outer | |
Re: See ... http://linux.softpedia.com/get/System/Operating-Systems/Linux-Distributions/Python-OS-87758.shtml also ... http://sourceforge.net/projects/cleese/ | |
Re: You should have listened and read Python snippet at ... http://www.daniweb.com/software-development/python/threads/465305/python-prime-number-code-not-working#post2026050 Actually, a good sieve algorithm will run N=1000000 in about 0.1 to 0.2 seconds. If you use Python module numpy, you can do this in 0.012 seconds. | |
Re: First ask the user what shape is wanted ... `shape = input("What shape do you want (triangle, square and rectangle): ")` Once the shape is given, follow it with a conditional statement like ... if shape == "rectangle": a = float(input("Enter length of side a: ")) b = float(input("Enter length … | |
Re: This might help ... http://www.eg.bucknell.edu/~hyde/Python3/TurtleDirections.html | |
Re: Is the problem that your friends don't have Python installed on their Windows computer? In what version of Python is your game coded in? See also: http://www.daniweb.com/software-development/python/threads/20774/starting-python/18#post1981507 | |
Re: If the number is large, use the Miller-Rabin primality test. | |
Re: On a Windows box: http://www.daniweb.com/software-development/c/code/216489/clear-the-screen-using-winapi-functions | |
Re: Use the regular swap, it makes your code simpler to maintain by others. | |
Re: Also run this test ... N = 20 # list() needed for Python3 # since range() is now a generator object print(list(range(2, int(N**0.5)+1))) ''' result ... [2, 3, 4] ''' I don't think this is what you want. | |
Re: Hmmm, I put it to the test ... ''' primelist_timing7.py yet another primelist timing for speed ''' import timeit def time_function(stmt, setup): """use module timeit to time functions""" # to enable garbage collection start setup with 'gc.enable();' #setup = 'gc.enable();' + setup t = timeit.Timer(stmt, setup) # doing 10 passes … | |
Re: Development time with Python is much faster than with C++ The main supporter of Python is Google and they rather successfully use Python internally. Python, being a high level language, complements the low level C++ language very well. So it is worthwhile knowing both. Python, similar to Java, is portable … | |
Re: We are probably sitting on a couple of thousand cruise missiles that have a limited shelf life. So it's “usem or losem”. That should help the rebels win. The only thing is that many of the "rebels" are extreme Islamists and AQ. If the extremists take over, it will make … | |
Re: Python3 is a more streamlined/modern version of Python. Python 2.7.x is the end of the Python2 line. Not all Python2 code will work with Python3, so Python 2.7 will be maintained for those folks who have a fair amount of Python2 code. Some of the popular Python3 improvements have been … | |
Re: I like the new features that come with the updates. | |
Re: Strange, never had any problems with numpy and Python33. I used the **numpy-MKL-1.6.2.win32-py3.3.exe** installer | |
Re: My preference for the Pygame event loop exit ... ''' PG_AnimatedLines1a.py draw animated corner lines with Python module pygame modified from: http://wordpress.com/tag/pygame-tutorial/ ''' import pygame as pg w = h = 500 size = 250 step = 10 pos = 0 maxlines = 40 black = (0, 0, 0) # … | |
Re: You are close. Just a reminder, don't use sum, min, max as variable names since they are functions in Python. I like to prefix with 'my'. Start with a high mymin value (let's say 100) and make it x if x is lower. With mymax you start low (zero) and … | |
Re: Another simple example is at ... http://www.daniweb.com/software-development/python/code/464630/a-ticker-for-long-messages-pythontkinter | |
A simple way to find duplicate words in a text. In this case the text is preprocessed to eliminate punctuation marks and set all words to lower case. | |
Re: Just got my yellow iPhone 5C to match my car and belly. You simply need a smartphone now-a-days so you can act like all the other idiots fingering the thing. | |
Re: Hint ... s = "question" print(s.endswith("ion")) # True | |
Re: Square and square root of what? | |
Re: At times the speed you can develop a program is important, that's where Python will be best. | |
Re: You use a Python list object this way ... number_item = int(input('How many items do you have? ')) mylist = [] # start with an empty list count = 1 while number_item > 0: item = input('{}) Name of item: '.format(count)) mylist.append(item) number_item -= 1 count += 1 # test … | |
Re: You mean something like this ... import time def get_int(prompt="Enter an integer: "): """this function will loop until an integer is entered""" while True: try: # return breaks out of the endless while loop return int(input(prompt)) except ValueError: print("Try again, value entered was not an integer.") x = get_int ("Enter … | |
Re: Simply add the numbers in each list together with function sum() and divide by the number of items in the list. |
The End.