python小算法!

def monkey_trouble(a_smile,b_smile):
  if a_smile==b_smile:
      return True
  else:
      return False

def sum_double(a,b):
  if a==b:
      sum=(a+b)*2
      return sum
  else:
      sum=a+b
      return sum

def diff21(n):
    if n>21:
        return (n-21)*2
    if n<=21:
        return 21-n

def parrot_trouble(talking,hour):
    if talking is True  and (hour<7 or hour>=21):
        return True
    else:
        return False

def makes10(a,b):
    if  a==10 or b==10:
        return True
    elif a+b==10:
        return True
    else:
        return False

def near_hundred(n):
    if n>=90 and n<=110:
        return True
    elif n>=190 and n<=210:
        return True
        
    else:
        return False

def pos_neg(a,b,negative):
    if a >0 and b<0 and negative is False:
        return True
    elif a<0 and b>0 and negative is False:
        return True
    elif a<0 and b<0 and negative is True:
        return True
    else:
        return False

def not_string(str):
    if len(str)>=3 and str[:3]=='not':
        return  str
    else:
        return 'not '+str

def missing_char(str,n):
    if len(str)<=n:
        return str
    else:
        str=str[0:n]+str[n+1:]
        return str

def front_back(str):

    n=len(str)
    if n==1:
        return str
    return str[n-1:]+str[1:n-1]+str[0:1]

def front3(str):
    return str[0:3]*3

http://codingbat.com/prob/p118366

def string_splosion(str):
    result=""
    i=1
    b=len(str)
    for j in range(0,b):

        result=result+str[o:j]
    
    return result


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值