In [1]:
#练习1
name=input('What is your name? ')
x=int(input('Enter the date of your birthday'))
if x>=420 and x<=520 :
print('Mr. right,你是非常有性格的金牛座!')
else:
print('Mr. right,你不是金牛座。')
In [2]:
#练习2
m = int(input('Enter an integer:'))
n = int(input('Enter another integer,and it is not zero'))
operation=input('What do you want to do with the two numbers?')
if operation.endswith('plus'):
print('The sum is: ',m+n)
else:
print('The result is: ',n/m)
In [3]:
#练习3
num = int(input('Enter the PM2.5 value: '))
if num>500:
print('应该打开空气净化器,戴防雾霾口罩')
else :
print('It is no problem')
In [5]:
#练习4
word=input('Enter a noun: ')
if word.endswith('y'):
print('变y为i加es')
elif word[-1] in 'sx' or word[-2:] in ['sh','ch']:
print('加es')
else:
print('加s')
In [6]:
#尝试性练习
print(' ',sep = ' ')
In [8]:
#挑战性练习
m = int(input('请输入要输入的整数个数,回车结束。'))
a = []
i = 0
while i <m:
a.append(int(input('Enter an integer: ')))
i = i + 1
print('',a)
b=a[:]
b.sort()
print('',b[3])
In [ ]:
In [ ]:
In [ ]: