Add chapter 13 Exercise
This commit is contained in:
parent
3153a3e180
commit
077f45289e
1 changed files with 11 additions and 0 deletions
11
thinkcspy/Chapter-13-Exercises/readposint.py
Normal file
11
thinkcspy/Chapter-13-Exercises/readposint.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
def readposint(num):
|
||||||
|
try:
|
||||||
|
val = int(num)
|
||||||
|
if val > 0:
|
||||||
|
print("You entered '{}'.".format(val))
|
||||||
|
else:
|
||||||
|
print("'{}' is not a positive.".format(val))
|
||||||
|
except Exception:
|
||||||
|
print("'{}' is not a number.".format(num))
|
||||||
|
|
||||||
|
readposint(input("Please enter a positive number: "))
|
||||||
Loading…
Reference in a new issue