Skip to content

Commit

Permalink
Example for sys Module
Browse files Browse the repository at this point in the history
  • Loading branch information
meleksabit committed May 6, 2022
1 parent 4db4e74 commit 99a5e64
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from random import randint
import sys

answer = randint(int(sys.argv[1]), int(sys.argv[2]))

while True:
try:
guess = int(input(f'guess a number {sys.argv[1]}, {sys.argv[2]}: '))
if 0 < guess < 11:
if guess == answer:
print('you are a genius!')
break
else:
print('hey bozo, I said 1~10')
except ValueError:
print('please enter a number')
continue
17 changes: 17 additions & 0 deletions randomgame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from random import randint
import sys

answer = randint(int(sys.argv[1]), int(sys.argv[2]))

while True:
try:
guess = int(input(f'guess a number {sys.argv[1]}~{sys.argv[2]}: '))
if 0 < guess < 11:
if guess == answer:
print('you are a genius!')
break
else:
print('hey bozo, I said 1~10')
except ValueError:
print('please enter a number')
continue

0 comments on commit 99a5e64

Please sign in to comment.