Wasaya/More examples
Jump to navigation
Jump to search
Truth machine
a = bool(int(io.read())) if a: while a do print(a) end end print(a)
Guessing number
a = random.randint(-50, 50) b = int(io.read_prompt("How many chances do you want to give yourself? ")) temp = b while b > 0 do c = int(io.read_prompt("What is the number you guessed?")) if c == a: print(f"Congratulations! You guessed it! The answer is {a}.") b = 0 d = (io.read_prompt("Do you want to play again? (y for yes, lowercase only)") == 'y')?true:false if !d: print("Thank you for playing!") break else: b = temp end elif c < a: print(f"{c} is too small! Please try again. You have {b - 1} more chances.") b -= 1 else: print(f"{c} is too large! Please try again. You have {b - 1} more chances.") b -= 1 end end