Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

ASSIGNMENT #1

Submitted by:
Numair Amin
Submitted To:
Mr Waqar
Reg No:
FA17-BCS-061-B
Date:
11-10-2020

Comsats University Islamabad


Sahiwal Campus
What Is Artificial Intelligence? Explain
Artificial intelligence refers to the simulation of human intelligence in machines that are
programmed to think like humans and copy their actions. The term may also be applied to
any machine that exhibits character associated with a human mind such as learning and
problem-solving.

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.

What is difference between Machine learning, Deep Learning and artificial


Intelligence?

 Artificial intelligence is a science like mathematics or biology. It studies ways to


build intelligent programs and machines that can creatively solve problems, which has
always been considered a human prerogative.

 Machine learning is a subset of artificial intelligence (AI) that provides systems


the ability to automatically learn and improve from experience without being explicitly
programmed. In ML, there are different algorithms (e.g. neural networks) that help to
solve problems.

 Deep learning, or deep neural learning, is a subset of machine learning, which


uses the neural networks to analyze different factors with a structure that is similar to the
human neural system.
What is the problem solving technique? And which type of steps exist in AI
explain with its examples.

Problem

A problem refers to a state where we wish to reach to achieve goal from a present state or
condition.

Problem Solving Technique

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.

Problem Solving Agent

The problem-solving agent performs precisely by defining problems and its several solutions.

Steps

Initial State
Actions
Transition Model
Goal Test
Path cost
Example

States: location of each numbered tiles and the blank tile.


Initial State: We can start from any state as the initial state.
Actions: left, right, up or down
Transition Model: It returns the resulting state as per the given state and actions.
Goal test: It identifies whether we have reached the correct goal-state.
Path cost: The path cost is the number of steps in the path where the cost of each step is 1.

How many IDE exist for python language programming also design a
comparison table of all IDE

1) PyCharm  It is an intelligent Python code


editor supports for CoffeeScript,
and TypeScript.
 Provides smart search to jump to
any file, symbol, or class.
 Smart Code Navigation
 It allows you to access
PostgreSQL, Oracle, MySQL,
SQL Server.
2) Spyder  Allows you to run Python code by
cell, line, or file.
 Plot a histogram or time-series, make
changes in dateframe or numpy array.
 It offers automatic code completion
and horizontal/vertical splitting.

3) IDLE  Search multiple files


 It has an interactive interpreter with
colorizing of input, output, and error
messages.
 Supports smart indent, undo, call tips,
and auto-completion.
 Enable you to search and replace
within any window.

4) Sublime Text 3  Allows you to highlight syntax.


 It has command Palette
implementation that accepts text input
from users.
 Handle UTF8 BOMs in .gitignore
files

5) Visual Studio Code  The editor provides smart code


completion based on function
definition, imported modules, as well
as variable types.
 You can work with Git as well as
other SCM providers
 Enable you to debug code from the
editor.

What is AIML (Artificial Intelligence Markup Language)? Explain.

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 stands for Artificial Intelligence Modelling Language. AIML is an XML based


markup language meant to create artificial intelligent applications. AIML makes it possible to
create human interfaces while keeping the implementation simple to program, easy to
understand and highly maintainable.

b. What is the basic tags 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.

Python has 6 standard data-types


 Numbers
 String
 List
 Tuple
 Set
 Dictionary
1) Numbers
In Numbers, there are mainly 3 types which include Integer, Float, and Complex.
Example:

a=5
print(a, "is of type", type(a))

Output: 5 is of type <class ‘int’>

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’}

Solve these given programs in python


a) Take a number from user and find the Factorial of this Number?
var = int(input("Enter a number: "))
factorial = 1

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.

values = input("Input some comma seprated numbers : ")

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.

km = int(input("Enter the value in kilometers: "))

# 1 Kilometre = 0.621371 Mile


ratio = 0.621371

# Converting km to miles.
miles = km * ratio

print("The entered value in Miles: ", miles)

OUTPUT
d) Write a program to swap two elements in a list.

values = input("Input some comma seprated numbers : ")

lis = values.split(",")

print(lis)

m=int(input("select which index is swap : "))

n=int(input("select which index is swap with : "))

lis[m], lis[n] = lis[n], lis[m]

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.

num1 = int(input("First number "))

num2 = int(input("Second number "))

num3 = int(input("Third number "))

numlist = [num1, num2, num3]

print(numlist)

avg = sum(numlist)/len(numlist)

print("The average is ", round(avg, 2))

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 :

You might also like