Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

10/2/23, 1:01 PM Untitled1.

ipynb - Colaboratory

freind_details=["ali", 20 , "engeneer"]
print(freind_details)

['ali', 20, 'engeneer']

movies =[
("the god father , 1972")
("the fight club" , 1998)
("the pulp fiction" , 2002)
]
for movie in movies:
movie name .= input ("enter the name of the movie:")
movie_year = int(input("enter the release year of the move:"))
new_movie = (movie name , movie_year)
movies.append(new_movies)
print(f"movie:{movie[0]}, release year: {movie[1]}")

Double-click (or enter) to edit

DICTIONARY IN PYTHON; \The dictionary is an unordered collection that contains key:value pairs separated by commas inside curly brackets.

KEY VALUE PAIRS.

DICTIONARY EXAMPLE:

thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}

def add_numbers(a,b):
result=a+b
return resultsum_result = add_numbers(5,3)
print(sum_result)

File "<ipython-input-1-423b2f2ee785>", line 1


def add_numbers(a,b):
^
SyntaxError: incomplete input

SEARCH STACK OVERFLOW

LAB 02 OCTOBER

environment = {'location': 'A', 'A': 'DIRTY', 'B': 'CLEAN'}


model={
'A':'dirty',
'B': 'clean'
}
#declaration of function for reflex agent working

def vacuum_cleaner(percept):
location = percept['location']
status = percept[location]
#update the model based on current percept
model['A'] = status
if status == 'DIRTY':
print(f"SUCKING UP DIRT AT {location}")

https://colab.research.google.com/drive/1ws6tIPNSrZ7aAYgm7JJ3WydOXrkxfR-d#scrollTo=GQBkodEUH5AJ&printMode=true 1/2
10/2/23, 1:01 PM Untitled1.ipynb - Colaboratory
environment[location] = 'CLEAN'
else:
print("MOVING TO ANOTHER LOCATION")
if location == 'A':
environment['location'] = 'B'
else:
environment['location'] = 'A'

for _ in range(5):
print("PERCEPT:", environment)
vacuum_cleaner(environment)
print("\n use of model",model)

PERCEPT: {'location': 'A', 'A': 'DIRTY', 'B': 'CLEAN'}


SUCKING UP DIRT AT A

use of model {'A': 'DIRTY', 'B': 'clean'}


PERCEPT: {'location': 'A', 'A': 'CLEAN', 'B': 'CLEAN'}
MOVING TO ANOTHER LOCATION

use of model {'A': 'CLEAN', 'B': 'clean'}


PERCEPT: {'location': 'B', 'A': 'CLEAN', 'B': 'CLEAN'}
MOVING TO ANOTHER LOCATION

use of model {'A': 'CLEAN', 'B': 'clean'}


PERCEPT: {'location': 'A', 'A': 'CLEAN', 'B': 'CLEAN'}
MOVING TO ANOTHER LOCATION

use of model {'A': 'CLEAN', 'B': 'clean'}


PERCEPT: {'location': 'B', 'A': 'CLEAN', 'B': 'CLEAN'}
MOVING TO ANOTHER LOCATION

use of model {'A': 'CLEAN', 'B': 'clean'}

https://colab.research.google.com/drive/1ws6tIPNSrZ7aAYgm7JJ3WydOXrkxfR-d#scrollTo=GQBkodEUH5AJ&printMode=true 2/2

You might also like