Professional Documents
Culture Documents
n=int(input('Enter the number of guests: '))
admissionCost=0;
for i in range(n):
age=int(input('Enter the Age of the user: '))
if age>=3 and age<=12:
admissionCost+=14.00
elif age>12 and age<65:
admissionCost+=23.00
elif age>=65:
admissionCost+=18.00
else:
continue
print("The Total Admission cost is {:.2f}".format(admissionCost))
OUTPUT
2. PRIME NUMBER OR NOT
a. # NAME: CHARAN SRIDHAR BHOGARAJU
b. # REGNO: 19BBS0094
c. import math
d. n=int(input("Enter the number is prime or not: "))
e. noOfFactor=0
f. if n>1:
g. for i in range(1,int(math.sqrt(n))+1):
h. if n%i==0:
i. noOfFactor+=1
j. if noOfFactor==1:
k. print("{} IS PRIME NUMBER".format(n))
l. else:
m. print("{} IS NOT A PRIME NUMBER".format(n))
n. elif n==1 or n==0:
o. print("{} is NEITHER PRIME NOR COMPOSITE".format(n))
p. else:
q. print("INVALID NUMBER PROVIDED")
r.
OUTPUT
import math
def primeNumber(n):
noOfFactors=0
if n==0 or n==1 or n<0:
return False
else:
for i in range(2,int(math.sqrt(n)+1)):
if n%i==0:
noOfFactors+=1
if noOfFactors==0:
return True
else:
return False
lb=int(input("Enter the Lower bound of the range: "))
ub=int(input("Enter the upper bound of the range: "))
print("PRIME NUMBER BETWEEN {} and {} are: ".format(lb,ub))
for i in range(lb,ub+1):
if primeNumber(i):
print(i,end=”, ”)
OUTPUT
i=5
while i>=1:
i=i-1
if i==3:
continue
print(i,"Charan")
j=5
while j>=1:
if j==3:
break
print(j,"Sridhar")
j=j-1
i=10
while i>=1:
print(i,"Anuradha")
if i==6:
break
i=i-1
OUTPUT