851 Posted Topics
![]() | |
Re: Chicago is heading for a high of -18 Celsius! I bet the crime rate is dropping. | |
Re: To install the PySide package on Linux use for Python2 --> `sudo apt-get install python-pyside` or for Python3 --> `sudo apt-get install python3-pyside` | |
Re: WinPython for Python 3.4 is at: http://sourceforge.net/projects/stonebig.u/files/Winpython_3.4/ | |
Re: Count the number of sleeping students. If it's more than 50% your teaching is boring. | |
Re: My suggestion would be to go with the coming year, so it would be Windows2015. | |
Re: I like this one: w, x, y, z = 1, 2, 3, 4 if w < x < y < z: print("w={} x={} y={} z={}".format(w, x, y, z)) | |
String input has changed from Python2's raw_input(prompt) to Python3's input(prompt). The old Python2 numeric input(prompt) has gone away with Python3, all input is now string input. The snippet shows a few lines you can add to your program such that you only need to use input(prompt). This makes your code … | |
Just another one of those silly polls. This one asks you to list the country that most associates with the type of food (or drink) you like. | |
Re: To get used to wxPython, I took vegaseat's mortgage calculator snippet written in Csharp and converted it to Python. I was surprised how easy it was: [code=python]# a simple mortgage calulator using wxPython # checked it out with the online mortgage calculator at: # http://www.mortgage-calc.com/mortgage/simple.php import wx import math class … | |
Does anybody have some experience with the iPython notebook? How do you get started? | |
Re: Here is a typical example: class Accumulator(object): ''' remembers self.n __call__() allows the class instance to be called as a function ''' def __init__(self, n=0): self.n = n def __call__(self, x): self.n += x return self.n # create an instance and initialize data = 4 acc = Accumulator(4) # remembers … | |
Re: You can also check: http://pymotw.com/2/multiprocessing/basics.html#importable-target-functions | |
Re: Double click on the source code and it will highlight. Then copy and paste without the line numbers. | |
Re: Interesting problem. You might want to test your functions one by one. ''' str_8bits.py represent a string in bytes of 8 bits ''' def string2bits(s): ''' convert a string of characters s to a string of 8 bits per character ''' b = "" for c in s: b += … | |
| |
Re: Don't forget that the hexadecimal representation of an integer is a string. | |
Re: A header file makes sense if you take into account future changes to the language. | |
Re: As I understand this: purchase_price = 50 selling_price = 100 - 10 gain = 40 | |
Re: Hint --> flowers = ['rose', 'bougainvillea', 'yucca', 'marigold', 'daylilly', 'lilly of the valley'] flowers2 = ['rose', 'bougainvillea', 'yucca', 'marigold', 'potato', 'daylilly', 'lilly of the valley'] print('potato' in flowers) # False print('potato' in flowers2) # True Please show some honest coding effort yourself, or you learn nothing and will be just … | |
Re: Please post your code as code. | |
Re: I am using the IDLE IDE that comes with Python 3.4 and it works well for my student needs. | |
Re: Real programmers learn C. It's fast, free, clean code, and easy to learn. http://www.tutorialspoint.com/cprogramming/cprogramming_pdf_version.htm Tool to use: http://www.codeblocks.org/ | |
Re: Editra is a neat Python IDE written in Python. There is a free download from: http://editra.org/ | |
| |
Re: Why would you like to replace words like food, help, work or love with xxxx? | |
Re: Computer analyst to programmer: "You start coding. I'll go find out what they want." | |
Re: The problem with OpenOffice is that it is written in Java and that makes it rather slow. | |
Re: Use either recursion or a while loop, but not both: def lengthR(mystring, count=0): ''' recursive function to count char in mystring excluding spaces ''' if mystring == '': return count mystring = mystring[0:-1] count += 1 if mystring.endswith(' '): count -= 1 print(mystring, count) # test return lengthR(mystring, count) mystring … | |
Re: Something like this usaully works: # Python2 (for Python3 use tkinter) import Tkinter as tk def show_image(): lbl['image'] = image_tk root = tk.Tk() # pick a .gif image file you have in the working folder # or give the full path fname = "House.gif" image_tk = tk.PhotoImage(file=fname) btn = tk.Button(root, … | |
Re: You can develop bad habits with any language! There are certain programming rules to follow. | |
Re: Study Java, there are a lot more jobs to have. To get a Python job you have to be very very good. Let us know when you start your third course. | |
Re: Follow the manual. There is no such thing as the `!==` operator. | |
Re: It is always good not to be tied to just the Microsoft platform. Rather than C# I would rather pick up Java. Once you are familiar with Java, C# will be easy to add. | |
Re: A tuple uses much less memory than a list. | |
Re: So what is your OS and type of FAT? I have seen similar errors with C# code too. | |
Re: Use a few temporary print() functions to see your problems. The brute force algorithm will take too much time with prime numbers in the higher ranges. So will the many calls to function is_divisible(). See the code snippet: http://www.daniweb.com/software-development/python/code/216871/prime-number-function-improvements-python for improvements and timing results. A sieve algorithm will be much … | |
Re: A character usually takes up one byte. | |
Re: Study this code, it will teach you how to pass arguments to and from functions: def main(): print('Welcome to the Fast Freight Shipping Company Calculator for Shipping Charges') print() #constants for the shipping prices weight_one_rate = 1.10 weight_two_rate = 2.20 weight_three_rate = 3.70 weight_four_rate = 3.80 #get the weight of … | |
Re: [QUOTE=idrk;1580773]this is stupid[/QUOTE]Sorry bud, not everyone can be as smart as the rest of us! | |
Re: I cleaned it up a little for you: def main(): print ('Welcome to the mpg calculator program: \n') # get the miles driven using the input function # input() gives a string so convert with float() miles_driven = float(input ("Please enter miles driven: ")) # get the gallons used using … | |
Re: In Python code blocks need to be properly indented. | |
Re: For hints on deciphering see: http://www.math.cornell.edu/~mec/2003-2004/cryptography/subs/hints.html | |
Re: You can pickle your code's local or global dictionary, this will save the name and value of each variable. |
The End.