python homework ——the third week

5-3

alien_color='green'
if alien_color=='green':

print('You get 5 points')

5-5

alien_color='yellow'
if alien_color=='green':
print('You get 5 points')
elif alien_color=='yellow':
print('You get 10 points')
else:
print('You get 15 points')


5-7

favorate_fruits=['apple','watermelon','banana']
if 'apple' in favorate_fruits:
print('You like apple')
if 'pear' in favorate_fruits:
print('You like pear')
if 'watermelon' in favorate_fruits:
print('You like watermelo0n')
if 'banana' in favorate_fruits:
print('You like banana')
if 'orange' in favorate_fruits:

print('You like orange')

5-10

current_users=['aaa','bbb','ccc','ddd','eee']
new_users=['fff','ggg','bbb','ccc','rrr']
for user in new_users:
if user in current_uses:
print('Please input another name')
else:

print('OK')

6-5

river_info={'nile':'Egypt',
            'Changjiang':'China',
            'Amazon':'Brazil',
            }
for river ,country in river_info.items():
print(river+' run through '+country)
for river in river_info.keys():
print(river)
for country in river_info.values():

print(country)

6-8

pi={'kind':'dog',
    'master':'xiaoming',
    }
aa={'kind':'cat',
    'master':'mike',
    }
ff={'kind':'dog',
    'master':'John',
    }
pets=[pi,aa,ff]
for pet in pets:

print(pet)

6-11

cities={
     'Guangdong':{
             'country':'China',
             'population':1000000,
             'fact':'.....',
             },
      'New York':{
             'country':'US',
             'population':13000,
             'fact':'.........',
             },
      'London':{
             'country':'British',
             'population':1500000,
             'fact':'.........',
             },
      }
for city,info in cities.items():
print(city + ' is in ' + info['country'] + ' with a population of '+
str(info['population']) + '.' + ' And it happened that ' +info['fact'])
      

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值