AI PRACTICLE FILE
(fuckkkkkkkkkkkkkkkkk, 40 hae)
(FIRST 12)
PROGRAM: 1
#Find the square of sum of first five natural numbers
addedNums = 0
for x in range(1,6):
addedNums += x
print(addedNums * addedNums)
PROGRAM: 2
input1 = int(input("Enter your number: "))
isPrime = False
for x in range(2,int(input1/2) + 1):
if input1%x==0:
isPrime = False
elif input1%x!=0:
isPrime = True
else:
if isPrime:
print("the given number, ", input1 ," is a prime
number")
else:
print("the given number, ", input1," is not a prime
number")
program: 3
input1 = float(input("Enter a number: "))
if input1%2==0:
print("the number ", input1," is even.")
elif input1%2!=0:
print("the number ", input1,"is odd.")
program: 4
input1 = int(input("enter a year: "))
if input1%4==0:
print("the year", input1," is a leap year.")
else:
print("the year",input1,"is not a leap year.")
Program: 5
input1 = int(input("Enter the number of finding factorials:
"))
isPrime = False
factors = []
for x in range(2,int(input1/2) + 1):
if input1%x==0:
isPrime = False
[Link](x)
elif input1%x!=0:
isPrime = True
else:
if isPrime:
print(input1, " = ", input1," * 1")
else:
all_factors = str(factors)
all_factors = all_factors.replace("[","")
all_factors = all_factors.replace("]","")
print("factorials of number", input1,"are: ",all_factors)
program: 6
input1 = input("Enter your character: ")
specialChars = ["!","@","#","$","%","^","&","*","-","_","+","="]
contains_special_char = False
for x in range(0,len(specialChars)):
if input1 == specialChars[x]:
print("contains a special character")
contains_special_char = True
if input1 == [Link]() and [Link]() != True and contains_special_char !=
True:
print("the given input is in upper case.")
elif input1 == [Link]() and [Link]() != True and contains_special_char !=
True:
print("the given input is in lower case.")
elif [Link]() == True and contains_special_char != True:
print("the given input is a digit.")
program: 7
all_the_numbers = []
for x in range(1,4):
print("Enter your ", x,"number")
Input = float(input(""))
all_the_numbers.append(Input)
else:
all_numbers = str(all_the_numbers)
all_numbers = all_numbers.replace("[","")
all_numbers = all_numbers.replace("]","")
print("the largest number in the given input",all_numbers ," ,IS:
",max(all_the_numbers))
program: 8, maine nahi kiya lol
program: 9, halat 8 ki tarah
program:10, program 10 ki maa ki….
Program: 11
#A = P(1 + R/100)t
input1 = float(input("Enter principle ammount: "))
input2 = float(input("Enter the rate: "))
input3 = float(input("Enter time: "))
ammount = input1 * (1 + input2/100) * input3
print(ammount)
Program: 12
#Find the length of sample_List=[11,24,35,17] using for loop.
sample_list = [11,24,35,17]
for x in range(1,len(sample_list) + 1):
print(x)