Last active
          August 29, 2015 14:12 
        
      - 
      
- 
        Save pvsousalima/18c681dad2738a81f3be to your computer and use it in GitHub Desktop. 
    Google's code resolutions
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | '''Given a function which produces a random integer in the range 1 to 5, | |
| write a function which produces a random integer in the range 1 to 7.''' | |
| import random | |
| # Produces a random integer in the range 1 to 5 | |
| def random_int15(): | |
| return random.choice(range(1,6)) | |
| # Produces a random integer in the range 1 to 7 using the previous function | |
| def random_int17(): | |
| choice = random_int15() | |
| return (random.choice(range(0,3))+choice) if (choice == 5) else choice | |
| # Execute choices list | |
| choices = [] | |
| for i in range(10): | |
| choices.append(random_int17()) | |
| print(choices) | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment