Professional Documents
Culture Documents
Assignment #1: Numair Amin
Assignment #1: Numair Amin
Submitted by:
Numair Amin
Submitted To:
Mr Waqar
Reg No:
FA17-BCS-061-B
Date:
11-10-2020
History
The field of AI research was founded at a workshop held on the campus of Dartmouth
College during the summer of 1956
Different Branches Of AI
1. Machine learning
2. Neural Network
3. Robotics
4. Expert Systems
5. Fuzzy Logic
6. Natural Language Processing
AI In Computer Science
Computer science defines AI research as the study of "intelligent agents": any device that
perceives its environment and takes actions that maximize its chance of successfully
achieving its goals. A more elaborate definition characterizes AI as "a system's ability to
correctly interpret external data.
Problem
A problem refers to a state where we wish to reach to achieve goal from a present state or
condition.
Problem solving is the act of defining a problem; determining the cause of the problem;
identifying, prioritizing, and selecting alternatives for a solution; and implementing a
solution.
The problem-solving agent performs precisely by defining problems and its several solutions.
Steps
Initial State
Actions
Transition Model
Goal Test
Path cost
Example
How many IDE exist for python language programming also design a
comparison table of all IDE
AIML stands for Artificial Intelligence Markup Language. AIML was developed by the Alicebot free
software community and Dr. Richard S. Wallace during 1995-2000. AIML is used to create or
customize Alicebot which is a chat-box application based on A.L.I.C.E. (Artificial Linguistic Internet
Computer Entity) free software.
a. What is the use of AIML? Explain with example.
<aiml> tag
<aiml> tag marks the start and end of a AIML document. It contains version and encoding
information under version and encoding attributes.
EX
<aiml version = "1.0.1" encoding = "UTF-8"?>
...
</aiml>
<category> tag
<category> tag is the fundamental knowledge unit of an ALICE Bot. Each category contains
−
User input in the form of a sentence which can be an assertion, question, and
exclamation etc. User input can contain wild card characters like * and _.
Response to user input to be presented by Alicebot.
Optional context.
EX
<category>
<pattern> HELLO ALICE </pattern>
<template>
Hello User
</template>
</category>
<pattern> tag
The <pattern> tag represents a user's input. It should be the first tag within the <category>
tag. <pattern> tag can contain wild card to match more than one sentence as user input.
EX
<category>
<pattern> HELLO ALICE </pattern>
<template>
Hello User
</template>
</category>
<template> tag
<template> tag represents the bot's response to the user. It should be the second tag within
the <category> tag.
EX
<category>
<pattern> HELLO ALICE </pattern>
<template>
Hello User
</template>
</category>
How many data types exist in python? Explain basic functions of each data
type with examples.
a=5
print(a, "is of type", type(a))
2) String
A string is an ordered sequence of characters.
Example:
String1 = "Welcome"
String2 ="To Python"
print(String1+String2)
Output: Welcome To Python
3) List
A list can contain a series of values.
List variables are declared by using brackets [ ]. A list is mutable, which means we can
modify the list.
Example:
List = [2,4,5.5,"Hi"]
print("List[2] = ", List[2])
Output: List[2] = 5.5
4) Tuple
A tuple is a sequence of Python objects separated by commas.
Example:
Tuple = (50,15,25.6,"Python")
print("Tuple[1] = ", Tuple[1])
Output: Tuple[1] = 15
5) Set
A set is an unordered collection of items. Set is defined by values separated by a comma
inside braces { }.
Example:
Set = {5,1,2.6,"python"}
print(Set)
Output: {‘python’, 1, 5, 2.6}
6) Dictionary
Dictionaries items are stored and fetched by using the key. Dictionaries are used to store a
huge amount of data.
Example :
Dict = {1:'Hi',2:7.5, 3:'Class'}
print(Dict)
Output: {1: ‘Hi’, 2: 7.5, 3: ‘Class’}
if var < 0:
print("Factorial not exist")
elif var == 0:
print("Factorial of 0 is 1")
else:
for i in range(1,var + 1):
factorial = factorial*i
print(factorial)
OUTPUT
b) Write a Python program which accepts a sequence of comma-separated
numbers from user and generate a list and a tuple with those numbers. Also
update tuple elements.
list = values.split(",")
tuple = tuple(list)
print('List : ',list)
print('Tuple : ',tuple)
#unlike list tuples cant be updated directly but we use another method to update tuples
indx=input("ENTER VALUE for tuple ")
tup2=(indx,);
tup=tuple + (tup2);
print(tup)
OUTPUT
c) Write a program to take kilometers from the user convert it into miles.
# Converting km to miles.
miles = km * ratio
OUTPUT
d) Write a program to swap two elements in a list.
lis = values.split(",")
print(lis)
print(lis)
OUTPUT
e) The program takes the elements of the list one by one and displays the
average of the elements of the list.
print(numlist)
avg = sum(numlist)/len(numlist)
OUTPUT
f) Write a python program to implement List operations (Nested List, Length,
Concatenation, Membership, Iteration, Indexing and Slicing)?
Code:
#1)Nested list
Lis=["aa",["bbb",["cc"]]]
print(Lis[0])
print(Lis[1][0])
print(Lis[1][1][0])
print("Length of list")
print(len(Lis))
#2)Lentgh of List
lis=["numair","amin","061"]
print("Length of list")
print(len(lis))
#3)Concatenation
lis=["numair","amin","A1 LAB"]
print("concatenation")
lis=lis+[" First ","Assignment","conca"]
print(lis)
#4)Membership
lis=["Com","uni","sahiwal"]
a=input("Enter any value which you want to check in list : ")
if a in lis:
print(a," is available in list")
else:
print(a," is not available in list")
#5)Iteration
lis=["Com","Numair","2"]
print(" Iteration : ")
for x in lis:
print(x)
#6)Slicing and Indexing
lis=["Comp","Eng","Num","Amin"]
print(" After Indexing")
print(" 0 :",lis[0])
print(" 1 :",lis[1])
print(" 2 :",lis[2])
print(" 3 :",lis[3])
print(" 4 :",lis[4])
print(" After Slicing : ")
print("from 2 index to so on :", lis[2:])
OUTPUT :