Page 1 of 2

Official "Help me with my homework" thread

Posted: Thu Sep 20, 2007 6:36 pm
by Merk
I don't think we've ever done one of these before so let's give it a shot!

I'm learning Python right now in one of my classes, it's a pretty simple language in terms of flexibility and syntax but god damn does my instructor go out of his way to word problems in the most obscure and ambiguous way ever. English is his second language and I can expect some errors here and there, but I have no idea what he's asking in this problem:

Code: Select all

Write a function called makeFunc taking a single string argument that will create and return a string. The return string will contain the text of a Python function (which will not take any arguments) whose name is the argument mentioned above and will simply print out this argument.

Write a program that calls makeFunc 4 times, each time passing to it an argument of the form 'fname1', 'fname2' etc. (So the first time you send it 'fname1' and so on). Each time you call makeFunc you'll get back the string. Write these strings to a file called autogen.py. Finally your program should add to autogen.py the code to call the functions you just generated.

After you run your program, you should have a file called autogen.py which if you then run should output

fname1
fname2
fname3
fname4
Perhaps I'm a dumbass, but don't know where to start. I THINK he wants us to have a string with a number concatenated onto it that represents the number of times the function has been called but I have absolutely no idea how to code that. Any help on this would be greatly appreciated.



I get bored at work (a lot) so let's post some difficult homework questions and learn some facts and shit! Knowledge is power!

Posted: Thu Sep 20, 2007 7:49 pm
by danc1005
You obviously just have to concatenate the string function makeFunc and add the argument to autogen.py and code it so that the multiple strings are returned in an argument for makeFunc.

Posted: Thu Sep 20, 2007 9:12 pm
by Potter
i really hope the above post was a joke

Posted: Thu Sep 20, 2007 11:08 pm
by Fluffyumpkins
I think you make a function that takes a string and writes it to a file. Do it 4 times in the same program so the file has 4 strings.

Also deport your professor.

Posted: Fri Sep 21, 2007 5:20 pm
by danc1005
Potter wrote:i really hope the above post was a joke
duh

Posted: Fri Sep 21, 2007 6:16 pm
by Merk
Guys seriously this is due monday

Posted: Fri Sep 21, 2007 9:24 pm
by Jeff Jeff Revolution
Anyone want to help me memorize all 212 of my play lines?

Posted: Fri Sep 21, 2007 9:58 pm
by BigBadOrc
Hm I forget how to code in python since i only used it for a few homework assignments myself so I'll write some javascript :D

Code: Select all

function makeFunc(str) {
  return "function " + str + "() { alert('" + str + "'); }";
}

function programLOLZ() {
   var funcName = "fname";
   for(var i=1;i<5;i++){
      writeToFile(makeFunc(funcName + i));
   }
   for(var(i=1;i<5;i++){
       writeToFile(funcName + i + "();\n");
   }
   runFile();
}
Yeah, i cheated a little since javascript doesn't have file I/O

Posted: Mon Sep 24, 2007 5:54 pm
by chocobojoe
to makeFunc you gotta get a black guy playing the slap bass and some other guy playing a guitar with wah-wah effect, then add some jazzy drums and maybe a trumpet or something, then another black guy singing some lead vocals about dancin and struttin.

Posted: Mon Sep 24, 2007 6:45 pm
by SoDeepPolaris
Jeff Jeff Revolution wrote:Anyone want to help me memorize all 212 of my play lines?
MAYBE INSTEAD OF COUNTING THEM YOU SHOULD MEMORIZE THEM DURDURDURDURDURRRRRRRRRRRRRRRRRRRRRRRRRRRR.

Posted: Mon Sep 24, 2007 7:56 pm
by elcuebee
TAZO TEA

Posted: Mon Sep 24, 2007 9:13 pm
by blackcat
SoDeepPolaris wrote:
Jeff Jeff Revolution wrote:Anyone want to help me memorize all 212 of my play lines?
MAYBE INSTEAD OF COUNTING THEM YOU SHOULD MEMORIZE THEM DURDURDURDURDURRRRRRRRRRRRRRRRRRRRRRRRRRRR.
:x

I'll help you if you need it Jeff.

Posted: Mon Sep 24, 2007 9:38 pm
by Jeff Jeff Revolution
SoDeepPolaris wrote:
Jeff Jeff Revolution wrote:Anyone want to help me memorize all 212 of my play lines?
MAYBE INSTEAD OF COUNTING THEM YOU SHOULD MEMORIZE THEM DURDURDURDURDURRRRRRRRRRRRRRRRRRRRRRRRRRRR.
It says in the beginning of the script exactly how many I have.

Also, thanks Katy, but the odds of you and I sitting down and practicing on an Indy Groove night are astronomical. I see an ITG machine, all thoughts go out the window.

Posted: Mon Sep 24, 2007 9:51 pm
by TaQa
I've got a problem from my Real Analysis class. I'm sure I can figure it out, I'm just lazy. But here it is:

Prove the closed ball is closed.

Yeah, sounds stupid, but we're supposed to use Cauchy sequences along with the good ol' epsilon delta garbage to prove it.

Posted: Mon Sep 24, 2007 11:21 pm
by BigBadOrc
TaQa wrote: Prove the closed ball is closed.
FILL WITH WATER SEE IF IT LEAKS LOLZ