Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Magic Number program written in Python 3
- #written by theniwo
- #Define variables
- #Define screen scrollup
- def cls(): print("\n" * 100)
- #Ask for input of number and tries
- #Set variable magic for the while loop
- magic=0
- #ask for a number between 1 and 10
- while not int(magic) in range(1,10):
- magic=int(input('Player One, enter magic number (between 1 and 10): '))
- #Ask for number of tries between 3 and 5.
- counts=0
- while not int(counts) in range(3,5):
- counts=int(input('How many tries 3-5? '))
- #Initialize the counter
- counter=1
- #clear the screen (Quick and dirty)
- cls()
- while counter<=counts:
- tries=counts-counter
- #Ask user for a number & evaluate!
- guess=int(input('Please guess the magic number: '))
- if guess<magic:
- if tries>1 or tries<1:
- print('Sorry, too low.', tries, 'tries left')
- counter=counter+1
- if tries==1:
- print('Sorry, too low.', tries, 'try left')
- counter=counter+1
- if guess>magic:
- if tries>1 or tries<1:
- print('Sorry, too high.', tries, 'tries left')
- counter=counter+1
- if tries==1:
- print('Sorry, too high.', tries, 'try left')
- counter=counter+1
- if guess==magic:
- print('Congratulations, that is the magic number!')
- break
- else:
- print('Sorry, no more tries left. The number was:',magic)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement