#1
Im in compsci lab and need to do this python program. and I cant.

I went to bed at 6 from studying for a midterm, woke at 8, studied while I ate, went to class at 9(did some studying), back to the room at 11, studied for an hour, midterm from 1-2. Nap now, right? Wrong. 3 hours of classes later Im halfway through lab and about to a) pass out and/or b) kill myself.

So apparently the dots are lines of code. It shouldnt be much less than them or a lot more.

So either laugh at me or help. Im almost too exhausted and tired of labs to care.


def every_nth(s, n):
#Return a string composed of every n_th character of s, starting from the
#first; that is, those characters with indices 0, 1*n, 2*n, ...

>>> every_nth('abcdefg', 2)
'aceg'
>>> every_nth('abcdefg', 3)
'adg'
>>> every_nth('abcdefg', 1)
'abcdefg'
>>> every_nth('abcdefg', 20)
'a'
>>>

.
.
.
.
.
.


def space_separate(s):
#Return a copy of string s with a space inserted between each of the
#characters of string s.

Use iteration over the characters of s.

>>> assert space_separate('abc') == 'a b c'
>>> assert space_separate('') == ''
>>>
.
.
.
.
.
.

def reverse(s):
#Return a string with the characters of string s in reverse order.

#Implement with a while loop and indexing.

>>> assert reverse('abc') == 'cba'
>>> assert reverse('') == ''
>>>
.
.
.
.
.
.

def test():
#Tests for this file.
# add a few tests for each function below using assert statements

if __name__ == '__main__':
test()
Quote by LuthierofTexas
You motorboatin son of a bitch.

Quote by ibaRGnez321
I love you LilVikingBoy.


Member of the Church of Gilmour

Dance, Kirby, dance!
(>")> <("< <( " )> (>"< <("^) (^")> <("v) (v")> (v"v) (^"v) (v"^) (^"^)
#2
Dude if I wasn't fried from Midterms and a ton of essays then I would be more than happy to help you, but my brain can't process anything at the moment
Random Metal-X fact:

Metal-X now sponsors: Blood Culprit!


"Ass Fuckingly Loud"

\m/^_^\m/ New Songs Up!!! \m/^_^\m/
#3
what kinda code is python? ive taken a C++ class. and am currently in a Java. idk how much help ill be tho
Quote by CodeMonk
Programming is an art form that fights back.


Quote by bob farrell

When Teenagers Crash Their Mothers Cars And Slash A Few Tires, The UG Justice Team Will Be There, And Justice . . . . . . . .Will Be Served!!!!
#4
I have no idea. :/
But I do know if youre in Java, and not dropping or failing, mad props to you.

I took it like 2 years ago. Confused the SHIT out of me. I think I ended up with a 6% in that class.
Quote by LuthierofTexas
You motorboatin son of a bitch.

Quote by ibaRGnez321
I love you LilVikingBoy.


Member of the Church of Gilmour

Dance, Kirby, dance!
(>")> <("< <( " )> (>"< <("^) (^")> <("v) (v")> (v"v) (^"v) (v"^) (^"^)
#5
haha confuses the hell outta me as we learn it. after we learn it tho, i feel like tard for not being able to get it. but thats just me. do you know if python is more like java or C++? like is it object oriented or line after line?
Quote by CodeMonk
Programming is an art form that fights back.


Quote by bob farrell

When Teenagers Crash Their Mothers Cars And Slash A Few Tires, The UG Justice Team Will Be There, And Justice . . . . . . . .Will Be Served!!!!
#6
line after line, I believe. I never did C++ but I did Visual Basic and it's KIND OF similar to that. Maybe Java, considering they both confuse the crap out of me.
Quote by LuthierofTexas
You motorboatin son of a bitch.

Quote by ibaRGnez321
I love you LilVikingBoy.


Member of the Church of Gilmour

Dance, Kirby, dance!
(>")> <("< <( " )> (>"< <("^) (^")> <("v) (v")> (v"v) (^"v) (v"^) (^"^)
#7
alright. ya line by line is C++. im taking VB right now. stupid language really, a lot of shit it does by itself is annoying/stupid and can crash easy. only good part is the whole visual thing
Quote by CodeMonk
Programming is an art form that fights back.


Quote by bob farrell

When Teenagers Crash Their Mothers Cars And Slash A Few Tires, The UG Justice Team Will Be There, And Justice . . . . . . . .Will Be Served!!!!
#8
agree. whoo I think the AI is filling them in for us. hopefully
Quote by LuthierofTexas
You motorboatin son of a bitch.

Quote by ibaRGnez321
I love you LilVikingBoy.


Member of the Church of Gilmour

Dance, Kirby, dance!
(>")> <("< <( " )> (>"< <("^) (^")> <("v) (v")> (v"v) (^"v) (v"^) (^"^)
#9
good luck with it. hey, when you figure out what those programs are? i wanna see what the python code is like.
Quote by CodeMonk
Programming is an art form that fights back.


Quote by bob farrell

When Teenagers Crash Their Mothers Cars And Slash A Few Tires, The UG Justice Team Will Be There, And Justice . . . . . . . .Will Be Served!!!!
#10
Here's the *hopefully* finished product. Hope you understand. Cause that would make one of us.


def space_separate(s):
#Return a copy of string s with a space inserted between each of the
#characters of string s.

#Use iteration over the characters of s.

if s == '':
return ''
separated = ''
for char in s:
separated += char + ' '
return separated[:-1]

def every_nth(s, n):
#Return a string composed of every n_th character of s, starting from the
#first; that is, those characters with indices 0, 1*n, 2*n, ...

answer = ''
index = 0
while index < len(s):
answer = answer + s[index]
index = index + n
return answer

def reverse(s):
#Return a string with the characters of string s in reverse order.
#Implement with a while loop and indexing.

answer = ''
index = 1
while index <= len(s):
answer = answer + s[-index]
index = index + 1
return answer

def test():
#Tests for this file.
# add a few tests for each function below using assert statements

assert space_separate('abc') == 'a b c'
assert space_separate('') == ''
assert every_nth('akdfks', 2) == 'adk'
assert reverse('reverse') == 'esrever'
print "Tests completed ok"

if __name__ == '__main__':
test()
Quote by LuthierofTexas
You motorboatin son of a bitch.

Quote by ibaRGnez321
I love you LilVikingBoy.


Member of the Church of Gilmour

Dance, Kirby, dance!
(>")> <("< <( " )> (>"< <("^) (^")> <("v) (v")> (v"v) (^"v) (v"^) (^"^)
#11
ya sorry i dont know python. looks like C++ a lot, but i dont remember a lot of C++
Quote by CodeMonk
Programming is an art form that fights back.


Quote by bob farrell

When Teenagers Crash Their Mothers Cars And Slash A Few Tires, The UG Justice Team Will Be There, And Justice . . . . . . . .Will Be Served!!!!