#function to check a number in a range
def fun(n):
if n in range(0,1000):
print("it is in range")
else:
print("out of range")
fun(10006)
out of range
#cards reducing to half
x=int(input("enter number of cards you have:"))
print("after reducing cards are:",x//2)
enter number of cards you have:7 after reducing cards are: 3
#generating a random number
from random import randint
num=eval(input("enter a positive number:"))
y=randint(num,num+10)
for i in range(y):
print("A",end='')
print()
enter a positive number:6 AAAAAAAAAAAAAAA
#billing problem
start_hr=eval(input("enter starting hour(0/23):"))
end_hr=eval(input("enter end hour(0/23):"))
if(end_hr>=start_hr):
print("total",(end_hr-start_hr)*5.50)
else:
print("total",(23+end_hr-start_hr)*5.50)
enter starting hour(0/23):5 enter end hour(0/23):4 total 121.0
#probabilities
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("percentge of doubles",100*count/10000)
percentge of doubles 16.89