Python 28
[Python 100] Python 100
5424322210
10
#!/usr/bin/python
# -*- coding: UTF-8 -*-
def age(n):
if n == 1: c = 10
else: c = age(n - 1) + 2
return c
print (age(5))
18
[Python 100] Python 100
| [ Web Proxy ] |
| Viewing: https://www.runoob.com/python/python-exercise-example28.html | [Back] [Original] |
[Python 100] Python 100
5424322210
10
18
[Python 100] Python 100
| Web Proxy Viewer | New URL | Original Page |
459***[email protected]
Python3
#!/usr/bin/python3 def fun(age,rank): #age rank if rank == 1: return age else: return fun(age+2,rank-1) print (fun(10,5))459***[email protected]
sunjl
136***[email protected]
:
#!/usr/bin/python # -*- coding: UTF-8 -*- def age(): n = 10 for i in range(1, 5): n = n + 2 print("5{0}".format(n)) age()sunjl
136***[email protected]
279***[email protected]
#!/usr/bin/env python3 #coding:utf-8 def age(n): if n==1: return 10 if n>1: return (n-1)*2+10 print(age(5))279***[email protected]
382***[email protected]
Python3
def fn(n): if n==1: return 10 return 2+fn(n-1) print(fn(5))382***[email protected]
iMax4ever
jia***@foxmail.com
Python3
def age(n): return 10 if not n-1 else age(n-1)+2 print(age(5))iMax4ever
jia***@foxmail.com