guess.jl 750 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env julia
  2. # File: guess.jl
  3. # Name: D.Saravanan
  4. # Date: 30/08/2020
  5. """ Program for number guessing game """
  6. option = "yes"
  7. while option == "yes"
  8. N = rand(1:1:100)
  9. print("\nI 'm thinking of a number! Try to guess the number I 'm thinking of: ")
  10. num = parse(Int, readline())
  11. while num != N
  12. if num < N
  13. print("Too low! Guess again: ")
  14. num = parse(Int, readline())
  15. elseif num > N
  16. print("Too high! Guess again: ")
  17. num = parse(Int, readline())
  18. end
  19. end
  20. if num == N
  21. print("That's it! Would you like to play again? (yes/no) ")
  22. global option = readline()
  23. end
  24. end
  25. println("Thanks for playing!")