In [39]:
def reverse(s):
words=[]
for i in range(s):
word=input('请输入一个字符,回车结束')
words.append(word)
for j in range(s-1,-1,-1):
print(words[j])
s=int(input('输入一个数字表示想输入的字符个数,回车结束'))
reverse(s)
In [30]:
def sanjiaoxing(x):
line="* "
blank=" "
n=int(input('输入一个整数,表示想要的行数 '))
if x==0:
for i in range(1,n+1):
print(line*i)
if x==1:
for i in range(1,n+1):
print(blank*(n-i)+line*i)
x=int(input('输入一个整数,0代表直角三角形,1代表等腰三角形 '))
sanjiaoxing(x)
In [36]:
def pl(word):
if word.endswith('y'):
return word[:-1] + 'ies'
elif word.endswith('sh'or'ch'or'x'or's'):
return word + 'es'
elif word.endswith('fe'):
return word[:-2] + 'ves'
elif word.endswith('f'):
return word[:-1]+'ves'
elif word.endswith('o'):
if word==['hero','Negro','tomato','patopa']:
return word+'es'
else:
return word+'s'
else:
return word + 's'
word=input('输入一个英文单词,回车结束')
pl(word)
Out[36]:
In [ ]: