Python 21
[Python 100] Python 100
10
(Python 2.0+)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
x2 = 1
for day in range(9,0,-1):
x1 = (x2 + 1) * 2
x2 = x1
print (x1)
1534
[Python 100] Python 100
| [ Web Proxy ] |
| Viewing: https://www.runoob.com/python/python-exercise-example21.html | [Back] [Original] |
[Python 100] Python 100
10
1534
[Python 100] Python 100
| Web Proxy Viewer | New URL | Original Page |
459***[email protected]
Python3
#!/usr/bin/python3 x = 1 for day in range(0,9): x = (x+1)*2 print(x)459***[email protected]
1001
176***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- m = [1] Tn = 1 for i in range(9): Tn = (Tn+1)*2 m.append(Tn) print(m[len(m)-1])1001
176***[email protected]
695***[email protected]
Python3
#!/usr/bin/python3 x1=1 n1=9 while n1>0: x1=(x1+1)*2 print(n1,x1) n1=n1-1695***[email protected]
1
249***[email protected]
#!/usr/bin/env python # -*- coding: utf-8 -*- def taozi(n): if n == 1: return 1 else: return (taozi(n-1)+1)*2 print taozi(10) #1
249***[email protected]
15z***[email protected]
Python2.x Python3.x
#!/usr/bin/python # -*- coding: UTF-8 -*- daypeach = [] daypeach.append(1) curpeaches = lambda x: (x + 1) * 2 for i in range(0, 9): daypeach.append(curpeaches(daypeach[i])) print('%d' % daypeach[9])15z***[email protected]
funzmg
fun***@gmail.com
Python 3.6
# -*- coding:UTF-8 -*- def fun(x): if x==10: return 1 else: return (fun(x+1)+1)*2 print(fun(1))funzmg
fun***@gmail.com
paul
fly***[email protected]
:
# -*- coding: UTF-8 -*- def peach(n): return 1 if n==1 else (peach(n-1)+1)*2 for i in range(1,11): print('%d%d,%d'%(i,peach(11-i),peach(11-i)/2+1))paul
fly***[email protected]
kuraki
117***[email protected]
Python3
def fun(day): if day==9: return 4 else: return (fun(day+1)+1)*2 for i in range(1,10+1): if i == 10: print('101') else: print(f'{i}{fun(i)}{int((fun(i)/2)+1)}')kuraki
117***[email protected]