|
I've just started watching the MIT lectures found here: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008 The videos are not clear enough to view the code. Is there some better quality video or do they realize their error and get a better quality video camera or something? Not trying to decipher blurry code.
|
# ¿ Aug 26, 2012 00:50 |
|
|
# ¿ Apr 27, 2024 08:14 |
|
Captain Capacitor posted:You can look at the course readings here which has most of the material for the course. Just realized that they actually zoom in to the coding later in the video so all is well. Have another question though. In the video they do operations such as 9/5 equals 1 and 'a' < 3 equals false. I understand the reason for this but I'm using Python 2.0 which gives answers of 1.8 and "TypeError: unorderable types: str() < int()" Are they using Python 1? If not what is the difference between their setup and mine?
|
# ¿ Aug 26, 2012 01:48 |
|
Another small question. I see that 25**.5==9**.5+16**.5 is false and I understand why. What is the correct way to work around this?
|
# ¿ Aug 26, 2012 06:21 |
|
how!! posted:25 ** .5 == 5 Oh gently caress, I think it's time for me to stop coding for the night I'm starting to lose it. Thanks for clarifying. Edit:I swear I have a real question now. The problem is: quote:A Pythagorean triplet is a set of three natural numbers, a b c, for which, Here is my code: code:
huhu fucked around with this message at 18:04 on Aug 26, 2012 |
# ¿ Aug 26, 2012 06:32 |
|
Thanks everyone for your input, I'm going to take a look at your suggestions now. Have another question. If I have a def such as prime_test(#) and I have it setup to print 'nprime' if it's not prime and 'prime' if it's prime. Another part of my program has if prime_test(#)=='prime' then do something else. If I type prime_test(5) I get prime but if I type prime_test(5)=='prime' I get false. How do I make these two things interact with each other? Here is my code so far. code:
huhu fucked around with this message at 20:56 on Aug 27, 2012 |
# ¿ Aug 27, 2012 20:45 |
|
Played around with my code and got:code:
Also, forgot to include a counter for my while loop and took me ten minutes to figure out that was the problem. huhu fucked around with this message at 21:08 on Aug 27, 2012 |
# ¿ Aug 27, 2012 20:58 |
|
I have this code:code:
|
# ¿ Sep 1, 2012 21:13 |
|
sund posted:continue Any suggestions for making this more efficient though? It took somewhere between two and five minutes to solve. Also, is making coding more efficient in regards to math problems mostly done by knowing more advanced theories? Like for example, here is another method for solving this problem: http://ca.answers.yahoo.com/question/index?qid=20100123221401AA7q4lR code:
|
# ¿ Sep 1, 2012 22:00 |
|
Thanks again for all of your input. Can anyone point me to a basic introduction to matrices and interacting with rows, columns, changing elements, adding, rows/columns, etc? I must be searching the wrong thing because I've been looking for twenty minutes and can't find anything useful.
|
# ¿ Sep 2, 2012 22:23 |
|
If I assign values to each of the letters such that a=1, b=2, c=3, etc, etc, how could I go about converting a string to a numerical value such as cat = 3 + 1 + 20? I would prefer a push in the right direction instead of a solution if possible. My thoughts so far is to set a=1 b=2 ... z=26 Then take a name such as "cat" and break it up and treat c a t as variables and sum these values. I'm just not sure how to identify each of the strings as variables. huhu fucked around with this message at 18:03 on Sep 8, 2012 |
# ¿ Sep 8, 2012 17:56 |
|
Ended up with a surprisingly fast code which went through about 5000 names in less than a second. I will check out dictionaries and ord now though thanks.code:
huhu fucked around with this message at 18:47 on Sep 8, 2012 |
# ¿ Sep 8, 2012 18:33 |
|
I'm trying to install the beautofulsoup4 module, my first attempt at installing a module, and I'm totally lost reading online guides. Could someone point me to an idiots guide to installing modules?
huhu fucked around with this message at 01:37 on Feb 4, 2016 |
# ¿ Feb 4, 2016 01:31 |
|
accipter posted:What OS? If you are on windows, install miniconda3, then open terminal and run: That's about as idiot-level as you can get. Thanks!
|
# ¿ Feb 4, 2016 02:43 |
|
accipter posted:What OS? If you are on windows, install miniconda3, then open terminal and run: Edit: Getting this: code:
huhu fucked around with this message at 01:30 on Feb 6, 2016 |
# ¿ Feb 6, 2016 01:13 |
|
accipter posted:I am guessing that you now have multiple Python versions installed. Run the following commands you should see something similar code:
Edit: Forgot the second part. code:
huhu fucked around with this message at 01:43 on Feb 6, 2016 |
# ¿ Feb 6, 2016 01:37 |
|
The folder I was in was C:\Python34 but I'm using Python35 which is in a completely different location.
|
# ¿ Feb 6, 2016 02:18 |
|
If I have a variable and I want to check if it's either a non-empty
|
# ¿ Feb 6, 2016 22:47 |
|
Illegal Move posted:Just out of curiosity, why do you need this? I'm scraping data from a language translator and depending on the inputs you give it: "father", "the father", "like father like son", you get something that's either a string, an empty string, or doesn't exist. There might be a more eloquent way to deal with this but I'm just trying to get through writing my first program. Thermopyle posted:try/except? huhu fucked around with this message at 00:53 on Feb 7, 2016 |
# ¿ Feb 7, 2016 00:47 |
|
code:
I'm writing a class with dictionary.openD(filename.txt) and I'm lazy and don't want to write dictionary.openD("filename.txt")
|
# ¿ Feb 13, 2016 18:38 |
|
Simplified question.code:
huhu fucked around with this message at 20:57 on Feb 13, 2016 |
# ¿ Feb 13, 2016 20:52 |
|
code:
code:
code:
code:
|
# ¿ Feb 21, 2016 19:14 |
|
Asymmetrikon posted:FEFF is a zero-width space. You've probably got one in your file. I've found this: http://stackoverflow.com/questions/17912307/u-ufeff-in-python-string Is a zero-width space the fact that's encoded in UTF-8? And how would I go about removing that? I've tried reading the instructions listed on the page and I don't understand it at all.
|
# ¿ Feb 21, 2016 19:33 |
|
I've got this code that is searching through a directory and trying to match files up to another directory. If the file in the first is found with the same name in the second, it'l move the file in the first directory to the second. code:
code:
code:
|
# ¿ Sep 19, 2016 22:32 |
|
cinci zoo sniper posted:Is it straightforward to implement something so that when you have script.py that imports stuff from library.py, you can also get it to make you a copy of both library.py and script.py in the output folder? I'm specifically after doing it through Python, doing that via OS would be trivial. Is this what you want? to_copy.py code:
code:
|
# ¿ Sep 20, 2016 15:31 |
|
Two things I'd suggest looking into are for loops which will run a loop a set amount of times and interupts which can stop other functions. I'm new to gpio stuff so you'll have to do some searching.
|
# ¿ Oct 22, 2016 17:21 |
|
Oops
|
# ¿ Oct 22, 2016 17:36 |
|
What Python Debugger do you guys use for Linux?
|
# ¿ Nov 23, 2016 16:16 |
|
Thermopyle posted:PyCharm or ipdb. Awesome Thanks. New Question, is there a cleaner way to write this? [code] columns_int = self.columns_int[:] columns_int.remove(self.column_with_id_int) self.columns_int_no_id = columns_int [code]
|
# ¿ Nov 23, 2016 20:25 |
|
After hours of frustration with a script I'm writing, I've come to realize I could have been using CSVs instead of Excel files. So, lesson learned, if you can deal with CSV files instead of Excel do it. If you're wondering why, Excel columns can start at 1 or "A" however everything in Python starts at 0.
|
# ¿ Nov 28, 2016 16:47 |
|
Has anyone ever been able to pin a python script to the start menu?
|
# ¿ Dec 21, 2016 23:46 |
|
Any suggestions for naming variables in Python for loops? I tend to just go with each or index but it gets quite confusing if I'm nesting loops. I also sometimes use, if my list is named something like "pairs" I'll do for each pair in pairs but that also seems a bit chaotic.
|
# ¿ Feb 5, 2017 22:21 |
|
I'm building a webcam that pushes images to the internet after capture. I found a script to upload the images to Dropbox and it works great. However, I've found an issue that if the internet goes down mid upload, no error is returned and the upload just gets stuck at whatever percent its at. This wouldn't really be an issue however my hackspace's internet is utter garbage and I suspect the internet will go down pretty often. Is there some nifty way to detect a stuck upload and break?
|
# ¿ Feb 10, 2017 01:27 |
|
Tigren posted:If your script uses the Dropbox v2 API, it looks like it raises a requests.exceptions.ConnectionError when it times out.
|
# ¿ Feb 10, 2017 05:31 |
|
Tigren posted:Can you link to the script you're using? The Dropbox python API is very straight forward if you just want to write your own. Oh that's much nicer than what I'm using, thanks.
|
# ¿ Feb 10, 2017 15:51 |
|
I'd say first calm down, you'll have a lot of experiences like this ahead so you'll need to manage them better. Second, you have this forum, ask specific questions more often. Perhaps start on a project that's not so hard.
|
# ¿ Feb 11, 2017 04:08 |
|
Uneducated question - why does memory management matter? I understand why it would with something like an Arduino which has almost no memory but why would that matter on something like a computer with so much more memory? For context, I'm reading about arrays vs linked lists. Related question: "To create an array, we must allocate memory for a certain number of elements"... when is this done? I thought a list was an array and I could just do my_list.append(x). What are they talking about that I'm missing? huhu fucked around with this message at 23:19 on Feb 15, 2017 |
# ¿ Feb 15, 2017 23:16 |
|
For anyone thinking about getting an Algorithms book for Python, don't buy this - https://www.amazon.com/Data-Structu...gorithms+python It boggles my mind that it managed to get 76 ratings of 4 stars. I'm catching at least one error every 5 to 10 pages and some of them are quite significant.
|
# ¿ Feb 24, 2017 23:20 |
|
code:
Is there a more elegant way to get values from a config file and then use them in a Python script or is this it?
|
# ¿ Feb 25, 2017 17:13 |
|
Could you guys give me an example of what your settings.py files my look like? Also, does the dot notation you use autofill in something like Pycharm? I'd like to be able to type my_config.a and have all the settings with a pop up. Perhaps I'm going about this wrong. Edit: I'm probing because the project I'm trying to work on might be useful for others. Probably not but I'd like the practice of making my stuff more user friendly. Edit2: I think I can clarify a bit. I have a code like so: code:
code:
code:
huhu fucked around with this message at 01:58 on Feb 26, 2017 |
# ¿ Feb 26, 2017 00:39 |
|
|
# ¿ Apr 27, 2024 08:14 |
|
onionradish posted:
This has been an amazing book to learn from and I still go back to it every other project or so.
|
# ¿ Feb 28, 2017 00:49 |