Untitled

mail@pastecode.io avatar
unknown
plain_text
8 days ago
1.2 kB
11
Indexable
Never
#Homework solution 

names =['ahmed','mohmmed','ibrahm','lena','rofida','khaled']
for i in range(3):
    print(names[i])

#Find the minimal number in list 
numbers = [11,2,5,32,3,6]
def findminimal(numbers):
    min = 99999999
    for i in numbers:
        if i<min:
            min=i
    print(min)   
findminimal(numbers)


# Ai Chatting partner
from mblock import event

questions = ['Hello','What is your name?','How are you?']
answers = ['Hi','My name is pico','Im fine ,thanks']

@event.greenflag
def on_greenflag():
    while True:
        answer=sprite.input('Say somthing')
        if sprite.answer in questions:
            print('Found')
            j=0
            while not questions[j]==sprite.answer :
                j=j+1
            sprite.say(answers[j],2)         
        else :
            newQuestion=answer           
            sprite.say('I do not understand!',2)
            answer=sprite.input('could you teach me')
            if sprite.answer== 'yes':
                questions.append(newQuestion)
                answer = sprite.input(str('What does ')+str(newQuestion)+str(' Mean?'))
                answers.append(answer)
            
            

#Homework (Search about AI branches )
Leave a Comment