Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,208,208 members, 8,001,908 topics. Date: Wednesday, 13 November 2024 at 06:34 PM

Anyone That Know Python Programming Should Help Me To Check The Eorr This - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Anyone That Know Python Programming Should Help Me To Check The Eorr This (2602 Views)

How Does It Take To Learn Python programming language Easy And Faster? / Learn And Practice Python Programming / Data Science Tutorial For Beginners With Python Programming Language (2) (3) (4)

(1) (Reply) (Go Down)

Anyone That Know Python Programming Should Help Me To Check The Eorr This by omoolabeads(m): 10:53pm On Apr 02, 2016
Create both a recursive function called recursive_factorial and iterative function called iterative_factorial that does the following

Accepts as parameter an Integer n
Computes the factorial of n
Returns the factorial of n

SOLUTION

import unittest

class RecursiveTestCase(unittest.TestCase):

def test_recursive_factorial_one(self):
result = recursive_factorial(4)
self.assertEqual(result, 24, msg="Inaccurate value"wink

def test_recursive_factorial_two(self):
result = recursive_factorial(0)
self.assertEqual(result, 1, msg="Inaccurate value"wink

def test_iterative_factorial_one(self):
result = iterative_factorial(5)
self.assertEqual(result, 120, msg="Inaccurate value"wink

def test_iterative_factorial_two(self):
result = iterative_factorial(12)
self.assertEqual(result, 479001600, msg="Inaccurate value"wink
Re: Anyone That Know Python Programming Should Help Me To Check The Eorr This by khaynoni(m): 10:59pm On Apr 02, 2016
Let's see your code. I guess this is one of Andela's ALGO lab question.
Re: Anyone That Know Python Programming Should Help Me To Check The Eorr This by tr3y(m): 11:49pm On Apr 02, 2016
Bro if you seriously expect someone to come and drop his code for you to copy then you should quit programming and face beads.

1 Like

Re: Anyone That Know Python Programming Should Help Me To Check The Eorr This by FrankLampard: 8:16am On Apr 03, 2016
tr3y:
Bro if you serious expect someone to come and drop his code for you to copy then you should quit programming and face beads.

Bro calm down na, u don't have the right to insult OP like that, if you can't help him ball out na, nobody is telling you to write full code so he can copy. Nawa oh.

1 Like

Re: Anyone That Know Python Programming Should Help Me To Check The Eorr This by FrankLampard: 8:18am On Apr 03, 2016
OP I don't know Python at all. If it was Java or PHP, I would have helped.
Re: Anyone That Know Python Programming Should Help Me To Check The Eorr This by tr3y(m): 11:05am On Apr 03, 2016
FrankLampard:


Bro calm down na, u don't have the right to insult OP like that, if you can't help him ball out na, nobody is telling you to write full code so he can copy. Nawa oh.

I'm not insulting OP in anyway, if you want people to help you, you have to show at least some effort by pasting the codes you have tried. He open a thread with just the Andela test code without showing us at least some part of codes he wrote himself.

If he had posted his own trial code, I will know how to point him to the right resources, to come here empty handed and expect to go with a bag full of codes for your assignment is just not right.

2 Likes

Re: Anyone That Know Python Programming Should Help Me To Check The Eorr This by Nobody: 11:07am On Apr 03, 2016
Where is your recursive factorial function
All i can see here is a unit test of the actual program.....
Re: Anyone That Know Python Programming Should Help Me To Check The Eorr This by dabanzy(m): 8:37pm On Apr 03, 2016
def recursive_factorial (n):
if n == 0:
return 1
else:
return n *recursive_factorial(n-1)
def iterative_factorial (n):
product = 1
for i in range(1,n + 1):
product = product * i
return product


op that should solve your problem
Re: Anyone That Know Python Programming Should Help Me To Check The Eorr This by omoolabeads(m): 7:29am On Apr 04, 2016
Thanks to everybody........... Am a Java Programming and i help people with beads making.
This question (Python)was giving to a friend and am trying to help him. Thanks God bless you all @dabanzy much love
Re: Anyone That Know Python Programming Should Help Me To Check The Eorr This by dabanzy(m): 10:01pm On Apr 06, 2016
@omoolabeads u're welcome
Re: Anyone That Know Python Programming Should Help Me To Check The Eorr This by antiomic: 12:21am On Jul 20, 2016
def recursive_factorial(n):
n = int(n)
if n <= 1:
return 1
else:
return (n * recursive_factorial(n - 1))

# print (recursive_factorial())


def iterative_factorial(n):
result = 1
for i in range(1, n+1):
result *= i
return result

# print (iterative_factorial())

(1) (Reply)

Thread For Those Who Got Accepted Into Decagon Software Engineering Program / My Website Date Is Not Correct Why??? / I Need Help With Android Studio!

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.