MazeDomains

Rain Delay

Feb 9th, 2020
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. print('Has rain delayed your cricket match? Use this handy calculator to work out how many overs you can play once the rain stops')
  2.  
  3. match_duration = float(input('How many whole hours in total does your cricket match go for? '))
  4. innings_overs = int(input('How many overs per innings? '))
  5. rain_shortened = float(input('How many hours left for the match after the rain delay? '))
  6. match_total_minutes = match_duration*60
  7. over_duration = match_total_minutes/innings_overs/2
  8. new_duration_minutes = rain_shortened*60
  9. shortened_total_overs = new_duration_minutes/over_duration
  10. new_overs_each_team = shortened_total_overs//2
  11. tea_duration = new_duration_minutes%over_duration
  12.  
  13. if rain_shortened > match_duration:
  14.     print('The rain-shortened match needs to be shorter than the normal match')
  15.    
  16. elif new_duration_minutes <over_duration*2:
  17.     print('You do not have enough time to play cricket but you do have ', tea_duration,'minutes for tea')
  18.    
  19. elif (shortened_total_overs%2) == 0:
  20.     print('You have exactly enough time to play ', new_overs_each_team,'overs each!')
  21.    
  22. elif (shortened_total_overs%2) != 0:
  23.     print('You have enough time to play ', new_overs_each_team,'overs each and ', round(tea_duration), 'minutes for tea')
Add Comment
Please, Sign In to add comment