def test_range_check(n):
if n in range(1,101):
print(" %s is in the range"%str(n))
else :
print(" %s is in outside the given range"%str(n))
num_cards = eval(input('How many cards do you have? '))
print('After reducing, you now have:', num_cards // 2)
How many cards do you have? 15 After reducing, you now have: 7
from random import randint
num = eval(input('Enter a positive integer: '))
num_times = randint(num, num+10)
for i in range(num_times):
print('A', end='')
print()
Enter a positive integer: 5 AAAAAA
start = eval(input('Enter starting hour (0-23): '))
end = eval(input('Enter ending hour (0-23): '))
if end >= start:
print('Total: ', (end-start)*5.50)
else:
print('Total: ', (24-start + end)*5.50)
Enter starting hour (0-23): 5 Enter ending hour (0-23): 9 Total: 22.0
from random import randint
count = 0
for i in range(10000):
r1 = randint(1, 6)
r2 = randint(1, 6)
if r1 == r2:
count += 1
print('Percentage of doubles:', 100*count/10000)
Percentage of doubles: 17.2