1 diamond
*
**
***
**
*
n = 5 _max = 2 * n - 1 a = [("*"*e).center(_max," ")for e in [2*i - 1 if i<=n else 4*n-2*i-1 for i in range(1,_max+1)]] for each in a: print each
2 prime in 100
for prime_num in range(2,101): for factor in range(2,prime_num/2): if prime_num%factor ==0:break else: print prime_num
3 abc -> bcd
#!/usr/bin/env python #coding:utf-8 import sys t = int(raw_input()) cases = 0 while t>0: t = t-1 cases = cases+1 line = raw_input() res = [] for ch in line: if ch==‘Z‘: res.append(‘A‘) else: res.append(chr(ord(ch)+1)) print "String #%d" % cases for ch in res: sys.stdout.write("%c" % ch) print ‘\n‘
时间: 2024-10-25 19:32:01