In [1]:
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))
In [2]:
test_range_check(101)
 101 is in outside the given range
In [3]:
test_range_check(51)
 51 is in the range
In [4]:
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? 25
After reducing, you now have: 12
In [5]:
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: 20
AAAAAAAAAAAAAAAAAAAAAAAA
In [7]:
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): 15
Enter ending hour (0-23): 23
Total:  44.0
In [8]:
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: 16.78
In [ ]: