565 Posted Topics
Re: Consider this example: def ls(): l = [1,2,3,4,5] for i in range(len(l)): print l[-(i+1):], Now try to figure out how to combine those lists and apply what **woooee** said to get your desired result. | |
Re: > I'm just glad it only happens once... :D Indeed, it happens only once, after every night of intense drinking. | |
Re: To be a little bit more complete than **plenty.groover**, here's DW's member rules, on which you sign up over registration on this site: **Do provide evidence of having done some work yourself if posting questions from school or work assignments.** | |
| |
Re: You could use a class to store all your employees information. Than, just add to your list those objects. Here's a small example: class Employee: def __init__(self, name, salary, desc): self.name = name self.salary = salary self.desc = desc def __str__(self): return 'Name: '+self.name+', Salary: '+str(self.salary)+', Description: '+self.desc def run(): … | |
Re: If using one-line examples, here, this might help you: lst, l = [('Meat', 'Milk'), ('Cake - Cookie'), ('Apple', 'Orange')], [] [l.append(tuple(i.split(' - '))) if '-' in i else l.append(i) for i in lst] print l Should produce this output: ''' [('Meat', 'Milk'), ('Cake', 'Cookie'), ('Apple', 'Orange')] ''' | |
Re: Beside the utterly ugly format you have presented us in this code, where's the problem in converting c++ to c? Post your conversion so far (of this code), so that we know you'd tried (and failed). | |
Re: What can I say, for your wine experience to be legendary, you always have to be accompanied by a bear. You'll probably want to give him just a beer, sice wine affects them greatly. | |
Re: Make a class which is recognized as an item, either a food item or a data item, or whatever. Read the first file (which is your database of products), and fill in the class' elements (which will be like this: id, name, type, price). To get the bill, read the … | |
Re: Look under the source tab if you want to get the source code of that library. Perhaps it would suite you in your needs. hg clone https://code.google.com/p/sla2pdf/ | |
Re: Make use of what Java already offers you: [Click Here](http://goo.gl/9F7iK) You can use the method `Integer.parseInt(string containing the number in some base, base)` method, but pay attention as digits from the string must be included in the radix of the 2nd argument. For example, if you want to parse the … | |
Re: You can. As **JamesCherrill** said, you'll need to add a functionality to each of your GUI components, so that it would handle the "events" generated by the user. Here's a small example. We have a button named `"Click me"`, which can be pressed. Near him there's a label named `"Clicks: … | |
Re: You could also use the [stringstream](http://www.cplusplus.com/reference/sstream/stringstream/) class from C++. Here's a little example: #include <iostream> #include <string> #include <sstream> #define SIZE 10 using namespace std; bool isInt(string s){ //checks if what the user inserted is an INTeger if (s=="" || s==" " || s == ".") return (false); string dash="-"; … | |
Re: Maybe this would help you. It does not generate the userid's, since you already have them, but it capitalize some parts of them: def mkusr(): name="John Doe" userid, rez, names=['jdoe','johndoe', 'jdoe02', 'johndoe02'], [], name.split() for i in userid: i = i.capitalize() for j in names: if j.lower() in i: i … | |
Re: You could use an iterative version of the factorial for big numbers: ''' >>> factorial(1000) 402387260077093773543702433923003985719374864210714632543799910429938512398629020592044208486969404800479988610197196058631666872994808558901323829669944590997424504087073759918823627727188732519779505950995276120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955735432513185323958463075557409114262417474349347553428646576611667797396668820291207379143853719588249808126867838374559731746136085379534524221586593201928090878297308431392844403281231558611036976801357304216168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868170164365024153691398281264810213092761244896359928705114964975419909342221566832572080821333186116811553615836546984046708975602900950537616475847728421889679646244945160765353408198901385442487984959953319101723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510907788019393178114194545257223865541461062892187960223838971476088506276862967146674697562911234082439208160153780889893964518263243671616762179168909779911903754031274622289988005195444414282012187361745992642956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226143974286933061690897968482590125458327168226458066526769958652682272807075781391858178889652208164348344825993266043367660176999612831860788386150279465955131156552036093988180612138558600301435694527224206344631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720559654228749774011413346962715422845862377387538230483865688976461927383814900140767310446640259899490222221765904339901886018566526485061799702356193897017860040811889729918311021171229845901641921068884387121855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218940694281434118520158014123344828015051399694290153483077644569099073152433278288269864602789864321139083506217095002597389863554277196742822248757586765752344220207573630569498825087968928162753848863396909959826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254742173582401063677404595741785160829230135358081840096996372524230560855903700624271243416909004153690105933983835777939410970027753472000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L ''' Here's the version: >>> def factorial(nr, prod = 1): for i in range(nr): prod *= (i + 1) return prod **[Edit:]** Nvm, already posted this above, didn't see it. **[Edit2:]** Nvm the first … | |
Re: How about putting your validation code, and as a mesure of precaution, an echo form of your input, so that you can see what you actually type in. while(True): ipt = raw_input("\\\\: ") print ipt if ipt == "stop": sys.exit(0); else: #rest of the program and than, post your results … | |
| |
Re: Daniweb member rules state this: **Do provide evidence of having done some work yourself if posting questions from school or work assignments**. I can't do anything to help you, since you haven't provided any code. We don't solve others homeworks/lab assignments. We can only help them solve specific problems related … | |
Re: And perhaps making the constructor from **Moschops** 2nd example public, or adding a static method which returns an object of type B. It's not that important for the situation at hand, but we should be careful with those things. Also, as **Banfa** pointed out, see the line number from your … | |
Re: > Ok, hmmm so you can't get the information from 'game' directly have to call Len on the combinations function. You don't call len on the combination function, you call len on the list function, which returns a list with all the combinations. To make it more clear `len(list(combinations(numbers, 6)))` … | |
Re: > On the other hand, I find comments such as "just google it" to be rude. In some cases, yes. For example, with those having a somehow complex problem and not knowing how to approach it. But, in most of the cases, Google is the OP's friend. I see a … | |
Re: Happy B-day Michael. So, I was born on 31st of October. One fun fact though: 2011 – The global population of humans reached seven billion. This day is now recognized by the United Nations as Seven Billion Day. There's a long list about this day, for those who are interested: … | |
Re: For a better view over your program, consider this extension to your program: add a new private member called name (string) which will hold the object name. put a `cout` in your desctructor with the name of your object: #include<iostream> #include <string> #include<conio.h> using namespace std; class Derived1 { int … | |
Re: So, you have a filename called `'numbers.txt'` which looks kinda like this: ''' 1 2 3 4 5 6 7 8 ''' You could make all that a list of strings, than work with them: l = [] with open('numbers.txt') as f: l = list(f) print l Or, you could … | |
Re: Interesting assignment? Now, just one thing though... your code? We can't help you if you don't show us what you'vd worked so far. | |
Re: > can any body suggest if same way can we perform the copy constructor as well. Written here, in your other thread: [Click Here](http://www.daniweb.com/software-development/cpp/threads/447011/memory-crash-not-seen-while-not-invoking-assignment-operator#post1937592) | |
Re: Here's a quick example (using what **snippsat** posted): import glob import time import os def dl(): t = 1361455258.34 #a generic moment of time, access time of a file from the folder Blah for files in glob.glob(r'E:\blah\*.txt'): print(files) #prints the content of the folder if (os.stat(files).st_atime>t): os.remove(files) #removes desired files … | |
Re: Indeed, deleting from a memory-contiguous-like container (such as a vector, or an array), requires a bit of time, because the system has to shift all the elements to get the desired result, but, it has some advantages. I see you mention a lot that you want to access the quesitons … | |
Re: > uhhhh... on a different computer No problem, we can wait. > do not know how to go to different def statement, As in: def printMenu(): print('1: Option 1\n2: Option 2\n3: exit') def menu(): answer = "" while(1): printMenu() answer = input("Choose: ") if (answer == "1"): #do stuff print("option … | |
Re: As a generic and quick method you could use the `in` keyword, to check if a string contains some characters, or substrings. l = string1.split() #split the string on the whitespaces for i in l: #for every string in l search for matches if '/' in i: print ("Date: "+i) … | |
Re: Well you have your problem explain, now start coding. Opening: reading/writing: [Click Here](http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files) Here's a small example of a csv file: *,*,*,*,*,*,*,*,*,*,* *,*,*,*,*,+,*,x,*,*,* *,*,*,*,*,+,*,x,*,*,* *,*,*,x,*,+,*,x,*,*,* *,*,*,*,*,+,*,x,x,*,* *,*,*,*,*,+,*,x,x,*,* *,*,*,*,*,+,*,*,*,*,* Where the `'*'` character marks an empty chair, `'x'` marks an occupied chair, and `'+'` marks the corridor. | |
![]() | Re: Had a mini holiday and went to my parents house (a farm in the countryside). Totally forgot about this 14th February thing. I hadn't had much time to think about it, being busy helping my "old man" on the farm chores. ![]() |
Re: > can anyone solve this problem for me ??? We're not here to solve your homework, we're here to help you figure out how YOU can solve it. > Class Array vaguely defined situation, what should we look for? if (last == data[size]) presumably should be if (last == size) … | |
Re: @**martineau** you are knew to our forums, but we have a rule going on here: if the thread is older than 3 months, there's no need to resurface it. I'm not saying that your advice is bad. I'm just saying that @**leegeorg07** posted his question 4 years ago, and I … | |
Re: Romanian (main), English, French, a bit of Italian and Dutch. > I learned some Finnish while I was living there, but it's literally one of the most complicated language in the world > Hungarian, I've been told, is impossible to learn. Both languages come from the same group of languages, … | |
Re: **** **** ******** ***** **** **** **** ****** **** **** **** ******* **** **** **** ******** **** **** **** **** **** **** **** **** **** ******** **** **** **** ******* **** **** **** ****** **** **** **** ***** **** **** **** **** ********** **************** ******** ******** **************** **** ************ **************** … | |
![]() | Re: > That right there is a warning 'this dude is an ####### and easily offended'. Any time 'eff you bitch' is your goto response (internally or out loud) you are not being nice for niceness sake you are being an ####### who wants to be appreciated. It's not about whether … |
Re: And? Where is your code so far? Have you tried to do something? Our members and rules topic says this: **Do provide evidence of having done some work yourself if posting questions from school or work assignments**. We won't do your homework for you, we'll help you on a specific … | |
Re: Here's the explanation ripped of the Java link **stultuske** provided: The most direct way to create a string is to write: String greeting = "Hello world!"; **In this case, "Hello world!" is a string literal**—a series of characters in your code that is enclosed in double quotes. **Whenever it encounters … | |
Re: If you're having trouble with an infinite loop, why don't you investigate the conditions of that loop? while( rules != 'N' && rules != 'Y' ) it sais that the loop will go on if `rules` is but the char `'N'` or `'Y'`, meaning anything else than those 2 chars … | |
Re: I don't know in other countries, but we have a specific beer beverage in our country, which suits best these events. It's called Timisoreana (after one of our cities)... In general, I prefer danish and/or czech beer. I'm intrigued by Budweiser being the last on the list (opposed to the … | |
Re: Try putting a getter for your `m_length` variable, used to set the `m_length` field in the copy constructor: const int getMlen() const{return m_length;} and Derived1::Derived1( const Derived1 &obj){ if(obj.getMlen()){ m_length = obj.getMlen(); cout<<obj.m_length; s=new char [m_length];//crash strncpy(s,obj.s,m_length); s[m_length-1]='\0'; } else{ s= new char[1]; s='\0'; //no need to perform deep copy … | |
Re: It's not about the concrete example, but the way you have to approach this problem, and the way to solve it. **inuasha** please post your `test.txt` file to clarify any doubts. | |
Re: delete obj; obj=obj2.create(); obj->show(); delete obj; This is legal. Even though you deleted the obj (freed that memory), the pointer is overwritten by the next line `obj = obj2.create();`. So by calling `obj->show();` after that, it would perfectly display `"Derived2"`, since obj points to a new Object of type Derived2. | |
Re: For the particular years you provided, this holds: public int[] getYears(){ int numbers[] = new int[3], dif=0; for (int i=0;i<years.length;i++) if (years[i]<0) years[i]*=-1; //normalising the array to positive integers for (int i=0;i<years.length;i+=2){ if (years[i]-years[i+1]>dif){ dif = years[i]-years[i+1]; numbers[0]=years[i]; numbers[1]=years[i+1]; numbers[2]=dif; } } return numbers; } now try to apply this … | |
Re: **Do provide evidence of having done some work yourself if posting questions from school or work assignments.** | |
Re: int[] count = new int[(years.length)/2]; yet you parse the array till the number 783, which is way greater than years.length/2. for(int l=0;l<=783;l=l+1) Why don't you go till the end of the actual array? for(int l=0;l<count.length;l++) | |
Re: Have you bother searching on google? Here, a useful link to aid you: [Click Here](http://www.cprogramming.com/tutorial/cfileio.html) or [Click Here](http://courses.cs.vt.edu/~cs2604/fall00/binio.html) | |
Re: As **adikimicky** pointed out, you're missing a declaration of your variable: BufferedImage img; presumably should be BufferedImage img, slate; since `slate` is undefined in your class, this error should appear: /** Exception in thread "main" java.lang.Error: Unresolved compilation problems: slate cannot be resolved to a variable slate cannot be resolved … | |
Re: If, persay, you have only 3 lines in your file: Jim,Gordon,Alex,Cross,Mr. Etc ***************************** 112,1114,111116,123,1342 and your names are split by some regex syntax, you could read the entire line, and than split it by the regex, thus getting all the names. I gave a simple example, for a `csv` file, … |
The End.