new to python and I have this assingment: I need to write a recursive function that takes paramaters (aString,nTimes ) and it needs to print the aString parameter the number of times specified by nTimes. I cannot use a for or while loop, just recursion. How would I go about doing this? all i know how to do is get it started and use recursion to call function again.
def printNtimes(aSt ring,nTimes):
I also know how to...
User Profile
Collapse
-
-
python cipher using a dictionary
i need to use a cipher but I have to used the assigned code in the ciphering i know how to do it, but i am not sure how to add my own dictionary. Here is what i have so far:
[cipher = {"a":"g", "b":"h", "c":"i", "d":"j", "e":"k", "f":"l", "g":"m", "h":"n",
... -
decimal to python using recursion
I need to write a code that take a decimal string and turns it into a binary number and i am new at python and have no clue how to do this:
[CODE=python]
def print_binary1(d ecimal_string):
bStr = '0'
while decimal_string > 0:
bStr = str(decimal_str ing % 2)
decimal_string = decimal_string >> 1
print bStr
... -
[CODE=python]def print_binary1(d ecimal_string):
bStr = ''
while decimal_string > 0:
bStr = str(decimal_str ing % 2)
decimal_string = decimal_string >> 1
print bStr
return bStr
if decimal_string == 0:
print bStr
return bStr
print_binary1(d ecimal_string )
[/CODE]
this is what i have and i know i...Leave a comment:
-
yeah i know how to do that but i am new to python and am unsure how the coding goesLeave a comment:
-
decimal to python using recursion
How do I convert a decimal integer to a binary number using a recursive function? I am really stuck on this one. any help?
No activity results to display
Show More
Leave a comment: