5-3到5-5
#5-3 alien_color='green' if alien_color=='green': print('you got five points!') alien_color='red' if alien_color=='green': print('you got five points!') #5-4 alien_color='red' if alien_color=='green': print('you got five points!') else: print('you got ten points') alien_color='green' if alien_color=='green': print('you got five points!') else: print('you got ten points') #5-5 alien_color='green' if alien_color=='green': print('you got five point') elif alien_color=='red': print('you got ten point!') else: print('you got fifteen points!') alien_color='red' if alien_color=='green': print('you got five point') elif alien_color=='red': print('you got ten point!') else: print('you got fifteen points!') alien_color = 'yellow' if alien_color == 'green': print('you got five point') elif alien_color == 'red': print('you got ten point!') else: print('you got fifteen points!')
结果:
you got five points!
you got ten points
you got five points!
you got five point
you got ten point!
you got fifteen points!