def test_range(n):
if n in range(3,9):
print( " %s is in the range"%str(n))
else :
print("the number is outside the given range.")
test_range(5)
5 is in the range
cards=eval(input("how many cards do you have? "))
print("after reducing, you have :",cards//2 ,'cards')
how many cards do you have? 8 after reducing, you have : 4 cards
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: 10 AAAAAAAAAAAAA
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): 8 Enter ending hour (0-23): 16 Total: 44.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.27