0% found this document useful (0 votes)
125 views11 pages

AI Project

The document contains details about several practical questions related to artificial intelligence. It includes scenarios about self-driving cars having to make moral decisions, the importance of data for AI, potential for bias in AI systems, and issues around unequal access to AI technology. Students are asked questions about each topic to help them understand the concepts. They are asked to provide reasoning for decisions self-driving cars may have to make, potential sources of bias, and how to address challenges like unemployment caused by AI.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views11 pages

AI Project

The document contains details about several practical questions related to artificial intelligence. It includes scenarios about self-driving cars having to make moral decisions, the importance of data for AI, potential for bias in AI systems, and issues around unequal access to AI technology. Students are asked questions about each topic to help them understand the concepts. They are asked to provide reasoning for decisions self-driving cars may have to make, potential sources of bias, and how to address challenges like unemployment caused by AI.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

DELHI PUBLIC SCHOOL BANGALORE - EAST

ARTIFICIAL INTELLIGENCE
Practical Questions (To be done in the Practical Journal)

Practical 1: Moral Issues: Self-Driving Cars


Scenario 1:
Let us imagine that we are in year 2030. Self-Driving cars which are just a concept in today’s time are
now on roads. People like us are buying them for ease and are using it for our daily transits. Of-course
because of all the features which this car has, it is expensive. Now, let us assume, one day your father is
going to office in his self-driving car. He is sitting in the back seat as the car is driving itself. Suddenly, a
small boy comes in front of this car. The incident was so sudden that the car is only able to make either of
the two choices:
1. Go straight and hit the boy who has come in front of the car and injure him severely.
2. Take a sharp right turn to save the boy and smash the car into a metal pole thus damaging the car as
well as injuring the person sitting in it.
With the help of this scenario, we need to understand that the developer of the car goes through all such
dilemmas while developing the car’s algorithm. Thus, here the morality of the developer gets transferred
into the machine as what according to him/her is right would have a higher priority and hence would be
the selection made by the machine.

Answer the following:

1. If you were in the place of this developer and if there was no other alternative to the situation, which
one of the two would you prioritise and why?

2. Let us now assume that the car has hit the boy who came in front of it. Considering this as an accident,
who should be held responsible for it? Why?
a. The person who bought this car
b. The Manufacturing Company
c. The developer who developed the car’s algorithm
d. The boy who came in front of the car and got severely injured

Practical 2: Data is the new gold.


The world of Artificial Intelligence revolves around Data. Every company whether small or big is mining
data from as many sources as possible. More than 70% of the data collected till now has been collected in
the last 3 years which shows how important data has become in recent times. It is not wrongly said that
Data is the new gold.

Answer the following:

1. Where do we collect data from?


2. Why do we need to collect data?

Practical 3: AI Bias

Another aspect to AI Ethics is bias. Everyone has a bias of their own no matter how much one tries to be
unbiased, we in some way or the other have our own biases even towards smaller things. Biases are not
negative all the time. Sometimes, it is required to have a bias to control a situation and keep things
working.
When we talk about a machine, we know that it is artificial and cannot think on its own. It can have
intelligence, but we cannot expect a machine to have any biases of its own. Any bias can transfer from the
developer to the machine while the algorithm is being developed.

Answer the following:

1. Majorly, all the virtual assistants have a female voice. It is only now that some companies have
understood this bias and have started giving options for male voices but since the virtual assistants came
into practice, female voices are always preferred for them over any other voice. Can you think of some
reasons for this?

2. If you search on Google for salons, the first few searches are mostly for female salons. This is based on
the assumption that if a person is searching for a salon, in all probability it would be a female. Do you
think this is a bias? If yes, then is it a Negative bias or Positive one?

Practical 4: AI Access

Since Artificial Intelligence is still a budding technology, not everyone has the opportunity to access it.
The people who can afford AI enabled devices make the most of it while others who cannot are left
behind. Because of this, a gap has emerged between these two classes of people and it gets widened with
the rapid advancement of technology. Let us understand this with the help of some examples:

AI creates unemployment
AI is making people’s lives easier. Most of the things nowadays are done in just a few clicks. In no time
AI will manage to be able to do all the laborious tasks which we humans have been doing since long.
Maybe in the coming years, AI enabled machines will replace all the people who work as labourers. This
may start an era of mass unemployment where people having little or no skills may be left without jobs
and others who keep up with their skills according to what is required, will flourish.
This brings us to a crossroads. On one hand where AI is advancing and improving the lives of people by
working for them and doing some of their tasks, the other hand points towards the lives of people who are
dependent on laborious jobs and are not skilled to do anything else.

Answer the following:

1. Should AI replace laborious jobs? Is there an alternative for major unemployment?


2. Should AI not replace laborious jobs? Will the lives of people improve if they keep on being unskilled?

AI for kids
A young boy in class 3 has got some Maths homework to finish. He is sitting at a table which has the
chatbot - Alexa on it, and he is struggling with his homework. Soon, he starts asking Alexa to answer all
his questions. Alexa replies with answers and the boy simply writes them down in his notebook.

3. Is it ethical to let the boy use technology to help in this manner?


Practicals on Python
(Type and run all below codes in Jupyter Notebook and paste the Jupyter Notebook snapshots of
the programs in the Practical Journal)

1. What will be the output of the following code?

x=2
while x<=10:
print(x)
x=x+1

output: 2
3
4
5
6
7
8
9
10

2. Write a program to check if a person can vote. (Example of if...else)

#A program to check if a person can vote


age=int(input("Enter Your Age: "))
if age>=18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

3. Write a program to check the grade of a student (Example of if...elif...else)

#To check the grade of a student

marks = 60
if marks > 75:
print("You get an A grade")
elif marks > 60:
print("You get a B grade")
else:
print("You get a C grade")

4. Write a program to input temperature and check if the weather is hot, moderate or cold.

# Code to input temperature and check if the weather is hot, moderate or cold.
temp = float(input("enter temperature in °Celcius: ")) # User inputs temperature in celcius
if temp > 35: # Check if temp > 35 or not
print("Weather is hot.")
# If temperature is not greater than 35, then it is either lesser than or equal to 35. Let us again use the
# alternative conditional statement - the elif condition here.
elif temp >= 20:
print("Weather is moderate.")
# If none of the above conditions stands true, the else statement executes.
else:
print("Weather is cold.")

5. Write a program to input marks of 3 subjects and print grades accordingly.

# Code to input marks of 3 subjects and print grades accordingly.


"""
A school has following rules for grading system:
a. Below 25 - F
b. 25 to 40 - E
c. 41 to 50 - D
d. 51 to 60 - C
e. 61 to 80 - B
f. Above 80 - A
Ask user to enter marks of AI, Maths and Science and print the corresponding grade.
"""
# Take in user input for three marks: AI, Maths and Science
AI = int(input("Enter marks of AI: "))
Maths = int(input("Enter marks of Maths: "))
Science = int(input("Enter marks of Science: "))

average = (AI + Maths + Science) / 3 # Average of marks is calculated

# Now, according to the average marks obtained, the grades are to be assigned.
# Note that any average can just have one type of grade. Hence, if-elif-else ladder will be used here.
if average > 80:
grade = 'A'

elif average > 60:


grade = 'B'

elif average > 50:


grade = 'C'

elif average > 40:


grade = 'D'

elif average > 25:


grade = 'E'
else:
grade = 'F'
# The final value of assigned grade gets printed below
print("Your grade = ", grade)
6. Write a program to check if an input number is less than, greater than or equal to 10

# Code to check if an input number is less than, greater than or equal to 10


a = int(input("enter a number:")) # User inputs a number
if a > 10: # Check if a is greater than 10
print("a > 10")
# if the previous if statement is false, then a is either smaller or equal to 10. Hence, we can use the elif
condition co check alternative condition.
elif a < 10:
print("a < 10")
# if both the above conditions doesn't satisfy, else block will be executed by default, and print a = 10
else:
print("a = 10")

7. Write the Python program to check the number entered is positive, negative or zero.
(Nested if Example)

# In this program, we input a number


# check if the number is positive or
# negative or zero and display
# an appropriate message
# This time we use nested if
num = float(input("Enter a number: "))
if num >= 0:
if num == 0:
print("Zero")
else:
print("Positive number")
else:
print("Negative number")

8. Write a program to find the sum of all numbers stored in a list. (Python for Loop)
# List of numbers
numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]
# variable to store the sum
sum = 0
# iterate over the list
for val in numbers:
sum = sum+val
# Output: The sum is 48
print("The sum is", sum)

9. Write a program to add natural numbers upto a user entered number. (Python while Loop)
# sum = 1+2+3+...+n
# To take input from the user,
# n = int(input("Enter n: "))
n = 10
# initialize sum and counter
sum = 0
i=1
while i <= n:
sum = sum + i
i = i+1 # update counter
# print the sum
print("The sum is", sum)

10. Write a program to find the whether a number is prime or not.


# taking input from user
number = int(input("Enter any number: "))

# prime number is always greater than 1


if number > 1:
for i in range(2, number):
if (number % i) == 0:
print(number, "is not a prime number")
break
else:
print(number, "is a prime number")

# if the entered number is less than or equal to 1


# then it is not prime number
else:
print(number, "is not a prime number")

11. Write a program to print numbers from 0 to 9.


for i in range(0,10):
print(i)
Nested Loops
Many times, the data which we work upon might not have just one dimension. It can be multi-
dimensional. Hence, we use the concept of Nested Loops in which one or multiple loops come under
the initial loop.
# sample code of nested for loops

for i in range(5): # Initial loop running from 0 to 4


print("start of i = ",i)

for j in range(5): # This is a nested loop as tand comes under the other loop
print ("j = ",j) # This print statement is under the nested loop

print("end of i = ",i)
print("end of nested for loops")

In the above code, for each iteration of for i block, a whole for j block is ran. this can be further nested to
as many nests as we want. Note that indentation plays a very important role in this. Changing the
indentation will result in unexpected answers or might throw an error.
12. Write programs to print the following patterns:

1
12
123
1234
12345

# A matrix is formed using 2 dimensions. To work in 2 dimensions, we need two loops working together i
n a nested looping configuration.
# Outer loop handles the number of rows
for i in range(1,6): # Loop runs from 1 to 5
# Inner loop to handle number of columns
for j in range(1, i + 1): # Loop runs from 1 to i+1
print(j, end = " ") # Print statement executes inside the nested loop
print() # Once the inner loop gets executed, code reaches to new line with this empty print command
******

*
**
***
****
*****
****
***
**
*

# In this code, two nested loops will be used: one for the increasing triangle and other for the decreasing tr
iangle

for i in range(1,6):
for j in range(1, i + 1):
print("*", end = " ")
print()
for i in range(1,5):
i=5-i
for j in range(1, i + 1):
print("*",end = " ")
print()
******
# In this code, read a number and print a right triangle using "*".
*
**
***
****
*****
n=int(input("Enter the number : "))
if n==0:
print("Enter a valid number.")
for x in range(1,n+1):
print("*" * x)
print("\n")

13. Write a program to print 0 to 5 using While loop


i=0 # Initialising variable i as 0
while i <= 5: # While loop runs till i is less than or equal to 5. i <= 5 is the condition mentioned
# for stopping the loop
print(i)
i=i+1 # While loop does not increment by itself.
# This statement increments the i variable for next iteration

14. Write a program to print odd numbers from 1 to n.


n = int( input("enter n: ") ) # User inputs any integer
i=1
while i <= n: # Loop runs from 0 till n
if i % 2 == 1: # Check if the number is odd or even
print(i) # Print the number if it is odd
i=i+1 # Increment the variable for next iteration

15. Write a program to print all numbers divisible by 6 between 1 to 100.

i=1
while i <= 100: # Loop starting from 1 till 100
if i % 3 == 0 and i % 2 == 0: # Check if the number is divisible by both 2 and 3to chec-
#-k its divisibility by 6
print(i," is divisible by 6") # Execute when the if statement is true
i=i+1 # Increment the variable for next iteration

16. Complete the code given below. Fill in the blanks to find the average percentage of a class with 1
5 students whose marks are given in the list marks.

marks = [40,54,81,95,76,69,35,63,99,58,73,85,56,62,93]
sum = 0 # Variable Intitiation
average = 0 # Variable Intitiation
for m in marks: # Loop statement to run through 15 student's marks
sum=sum+m # Statements to calculate average % of a class of 15 students
average = sum/15 # Calculate average percentage of the class
print(average) # Print average percentage
Output: 69.26666666666667
PYTHON LISTS

17. Predict the output:

List= ['G','O','O','D','M','O','R','N','I','N','G']
print(List)
print(List[3:8])
print(List[5:])
print(List[:])
print(List[:-7])
print(List[-6:-1])
print(List[::-1])

Answers:
['G', 'O', 'O', 'D', 'M', 'O', 'R', 'N', 'I', 'N', 'G']
['D', 'M', 'O', 'R', 'N']
['O', 'R', 'N', 'I', 'N', 'G']
['G', 'O', 'O', 'D', 'M', 'O', 'R', 'N', 'I', 'N', 'G']
['G', 'O', 'O', 'D']
['O', 'R', 'N', 'I', 'N']
['G', 'N', 'I', 'N', 'R', 'O', 'M', 'D', 'O', 'O', 'G']

18. What are the three methods to add elements to the List. Give examples for each.
We can add elements to any list using the following three methods :

1) append() method- Adds an element to the end of the List. Other lists can also be added.

List = []
List2 = ['Good', 'Morning']
List.append(1)
List.append(2)
List.append(List2)
print(List)
Output: [1, 2, ['Good', 'Morning']]

2) insert() method – Inserts an element at the defined index.

List = [1,2,3,4]
List.insert(3, 12)
List.insert(0, 'Kabir')
print(List)
Output: ['Kabir', 1, 2, 3, 12, 4]
3) extend() method- Add multiple elements at the same time at the end of the list.

List = [1,2,3,4]
List.extend([8, 'Artificial', 'Intelligence'])
print(List)

Output: [1, 2, 3, 4, 8, 'Artificial', 'Intelligence']


19. What are the two methods to remove elements from the List. Give examples for each.
Elements from a list can removed using the two methods :
1) remove() method – Removes an element from the list.

List = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,12]


List.remove(5)
List.remove(6)
print(List)

Output: [1, 2, 3, 4, 7, 8, 9, 10, 11, 12]

2) pop() method -Removes and returns an element from given index, otherwise removes the last element.

List = [1,2,3,4]
List.pop()
print(List)
List.pop(1)
print(List)

Output: [1, 2, 3]
[1, 3]

20. Write a program to print numbers from the list. ( test_list = [2,4,6,8,10] )
test_list = [2,4,6,8,10] # Sample list, (sequence = list of numbers)
for i in test_list: # elements of this list will be printed till the list terminates
print(i)

21. Write a program to add 2 to each element of a list and print numbers from the list.

test_list = [1,4,8,16,-1]
for num in range( len(test_list) ): # len(list_name) gives us the length of the list.
test_list[num] = test_list[num] + 2
print(test_list)

22. Write a program to enter weight of 15 students. Find the lightest of all.
a = [] # Empty List
for i in range(15): # 15 students need to enter their weight. Therefore, the loop runs for 15 times.
a.append( int( input("Enter number " + str(i + 1) + ":") ) ) # Weights entered by the user are appended in
the empty list a one by one as the loop executes.
print(a) # Print the entered values
min = a[0] # Initiate a variable min with the first entry
for i in range(15): # The loop again iterates for 15 times to check which element is the smallest.
if a[i] < min: # If the element is less than the min value,
min = a[i] # min value is updated with the new smaller value.
print(min)
23. Write a program to find sum of 10 numbers in a list.
test_list = [1,8,29,-54,-77,29,15,38,49,-39] # Sample List
sum = 0 # Variable to store the sum of list elements
for num in test_list: # Each element of the list is called and the loop iterates for len(test_list) times
sum = sum + num # The element called is added to the sum variable. Like this, all the elements get
added upto the sum variable
print("sum of the list = ",sum)

24. Write a program to add the elements of the two lists.


a=[1,2,3,4]
b=[5,6,7,8]
c=[]
if len(a)!=len(b):
print("The lists are of different sizes.")
else:
for x in range(len(a)):
c.append(a[x]+b[x])
print(c)

**********

You might also like