THIS PROGRAM GUESSES THE NUMBER YOU PICKED
You pick a number, keep it in your mind. You won't be asked for the number. The program is then gonna ask you a few questions. Answer them and using math, it will guess your number.
yeah the same as @Bookie0 said
import sys, os, curses
And this is the code:
st = 0.04
for letter in str:
For slowprint, you should make it in a function:
import sys, os, curses import time # And this is the code: st = 0.04 def sp(str): for letter in str: sys.stdout.write(letter) sys.stdout.flush() time.sleep(st) print()
I usually put it at 0.04 because it prints it not too fast and not too slow. But you can change it. Just change the value after st
Each time you want to do this typewriter effect, just do:
here's how you did it. It's WAY EASIER to understand if I made the list shorter. The list and yes or no questions are part of the trick in this program. Let's say I asked you to have a number in this list
[1, 2, 3, 4, 5, 6]. Let's say you chose 2. The first question he asks is even or prime by asking if the number is in this list
[1, 3, 5]. this already halves the chance of our answer. We say no. He now knows that it is an even number. He mixes it a little by asking whether it is in this list
[1, 4, 5] (changed some numbers). You say no. Ok, now he knows its an even number that is not 4. The final question:
[1, 2, 4]. Is it in this? He already knows it isnt 4 and 1, so if you say yes, its 2 but if you say no, its 6! You say yes and the number is determined as 2! Tricky, yet simple!