Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Airtificial intelliegene, Thesis of Artificial Intelligence

"AI" redirects here. For other uses, see AI (disambiguation), Artificial intelligence (disambiguation), and Intelligent agent. Part of a series on Artificial intelligence Artificial intelligence prompt completion by dalle mini.jpg Major goals Approaches Philosophy History Technology Glossary vte Artificial intelligence (AI) is intelligence—perceiving, synthesizing, and inferring information—demonstrated by machines, as opposed to intelligence displayed by humans or by other animals. Example tasks in which this is done include speech recognition, computer vision, translation between (natural) languages, as well as other mappings of inputs.[1] AI applications include advanced web search engines (e.g., Google Search), recommendation systems (used by YouTube, Amazon, and Netflix), understanding human speech (such as Siri and Alexa), self-driving cars (e.g., Waymo), generative or creative tools (ChatGPT and AI art), automated decision-making, and competing at the highest level in strategic

Typology: Thesis

2022/2023

Uploaded on 06/16/2023

sandeep-kumar-80
sandeep-kumar-80 🇮🇳

2 documents

1 / 38

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
A PRACTICAL FILE
OF
ARTIFICIAL INTELLIGENCE
SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENT FOR
THE
AWARD OF THE
DEGREE OF
BACHELORS IN
COMPUTER APPLICATION(BCA)
Subject code:- UGCA1951
Submitted To: Submitted By:
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26

Partial preview of the text

Download Airtificial intelliegene and more Thesis Artificial Intelligence in PDF only on Docsity!

A PRACTICAL FILE

OF

ARTIFICIAL INTELLIGENCE

SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENT FOR

THE

AWARD OF THE

DEGREE OF

BACHELORS IN

COMPUTER APPLICATION(BCA)

Subject code:- UGCA

Submitted To: Submitted By:

INDEX

S.No Program Page No. Date Remarks

  1. Learn the building blocks of logic programming in python
  1. Python script for comparing mathematical expressions and finding out unknown values
  1. Use logic programming in python to check for prime number.
  1. Python program to display calendar 6-7 29-1-
  2. Python program to print the largest element in an array
  1. Python program to print the largest element in an array
  1. Python program to print the sum of all elements in an array
  1. Python program to sort the elements of an array in ascending order
  1. (^) Python program to sort the elements of an array in descending order
  1. Use logic programming in python parse a family tree and infer the relationships between the family members
  1. Python Script For Building A Puzzle Silver 14-15 20-2-
  2. Implementation of uninformed search techniques in python
  1. Implementation of heuristic search techniques in Python
  1. Python script for tokenizing text data 28-31 27-2-
  2. Extracting the frequency of terms using a Bag of Words model
  1. Python code for visualizing audio speech signal
  1. Python^ code^ for^ Synthesizing^ tones^ to^ generate musics

x = 40 y = 12 add = x + y sub = x - y pro = x * y div = x / y print(add) print(sub) print(pro) print(div)

Q2. Python script for comparing mathematical expressions and finding out

unknown values

Ans:-

Q3. Use logic programming in python to check for prime number.

Ans-

num = 29

To take input from the user

#num = int(input("Enter a number: "))

define a flag

variable flag = False

prime numbers are greater than

1 ifnum> 1:

check for factors

fori in range(2, num): if (num % i) == 0:

if factor is found, set flag to True

flag = True

break out of loop

break

check if flag is True

if flag: print(num, "is not a prime number") else: print(num, "is a prime number")

Output2:- Output3:-

Output 4:-

Output 5:-

#Initialize array arr = [25, 11, 7, 75, 56]; #Initialize max with first element of array. max = arr[0]; #Loop through the array fori in range(0, len(arr)): #Compare elements of array with max if(arr[i] > max): max = arr[i];

Q6. Python program to print the largest element in an array

Ans:-

Q7.Python program to print the sum of all elements in an

array Ans:-

#Initialize array arr = [1, 2, 3, 4, 5]; sum = 0; #Loop through the array to calculate sum of elements fori in range(0, len(arr)): sum = sum + arr[i];

Q8. Python program to sort the elements of an array in ascending

order Ans:-

#Initialize array arr = [5, 2, 8, 7, 1]; temp = 0; #Displaying elements of original array print("Elements of original array: "); fori in range(0, len(arr)): print(arr[i], end=" "); #Sort the array in ascending order fori in range(0, len(arr)): for j in range(i+1, len(arr)): if(arr[i] >arr[j]): temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; print(); #Displaying elements of the array after sorting print("Elements of array sorted in ascending order: "); fori in range(0, len(arr)):

Output 8:-

Output9 :-

def test(nums): return nums.count(19) == 2 and nums.count(5) >= 3 nums = [19,19,15,5,3,5,5,2] print("Original list:") print(nums) print("Check two occurrences of nineteen and at least three occurrences of five in the said list:") print(test(nums)) nums = [19,15,15,5,3,3,5,2] print("\nOriginal list:") print(nums) print("Check two occurrences of nineteen and at least three occurrences of five in the said list:") print(test(nums)) nums = [19,19,5,5,5,5,5] print("\nOriginal list:") print(nums) print("Check two occurrences of nineteen and at least three occurrences of five in the said list:") print(test(nums))

Q10. Use logic programming in python parse a family tree and infer the

relationships between the family members.

Ans-

class Tree: def init (self, val=None): if val != None: self.val = val else: self.val = None self.left = None self.right = None tree = Tree(20) tree.left = Tree(18) tree.right = Tree(22) print(tree.left.val) print(tree.right.val)

Q11.Python Script For Building A Puzzle

Silver. Ans-

Q12.Implementation of uninformed search techniques in python.

Ans.Uninformed Search Algorithms: The search algorithms in this section have no additional information on the goalnode other than the one provided in the problem definition. The plans to reach thegoal state from the start state differ only by the order and/or length of actions. Uninformed search is also called Blind search. The following uninformed search algorithms are discussed in this section.

  1. Depth First Search
  2. Breadth First Search
  3. Uniform Cost Search Each of these algorithms will have:  A problem graph, containing the start node S and the goal node G.  A strategy, describing the manner in which the graph will be traversed to get toG  A fringe, which is a data structure used to store all the possible states (nodes)that you can go from the current states.  A tree, that results while traversing to the goal node.  A solution plan, which the sequence of nodes from S to G.  Depth-first search (DFS):- is an algorithm for tree traversal on graph or tree data structures. It can be implemented easily using recursion and data structures like dictionaries and sets.  The Algorithm
  4. Pick any node. If it is unvisited, mark it as visited and recur on all its adjacent nodes.
  5. Repeat until all the nodes are visited, or the node to be searched is found.  Implementation Consider this graph, implemented in the code below:

Using a Python dictionary to act as an adjacency

list graph = { 'A' : ['B','C'], 'B' : ['D', 'E'], 'C' : ['F'], 'D' : [], 'E' : ['F'], 'F' : [] } visited = set() # Set to keep track of visited nodes. defdfs(visited, graph, node): if node not in visited: print (node) visited.add(node) for neighbour in graph[node]: dfs(visited, graph, neighbour) # Driver Code Program:

Breadth-first search (BFS) IT is an algorithm used for tree traversal on graphs or tree data structures. BFS can be easily implemented using recursion and data structures like dictionaries and lists.  The Algorithm

  1. Pick any node, visit the adjacent unvisited vertex, mark it as visited, display it, and insert it in a queue.
  2. If there are no remaining adjacent vertices left, remove the first vertex from the queue.
  3. Repeat step 1 and step 2 until the queue is empty or the desired node is found.  Implementation Consider the graph, which is implemented in the code below:

graph = { 'A' : ['B','C'], 'B' : ['D', 'E'], 'C' : ['F'], 'D' : [], 'E' : ['F'], 'F' : [] } visited = [] # List to keep track of visited nodes. queue = [] #Initialize a queue defbfs(visited, graph, node): visited.append(node) queue.append(node) while queue: s = queue.pop(0) print (s, end = " ") for neighbour in graph[s]: if neighbour not in visited: visited.append(neighbour) Program:-