Untitled

mail@pastecode.io avatar
unknown
plain_text
10 days ago
1.4 kB
9
Indexable
Never
#Homework solution
names = ['khaled','ibrahem','abdelrahman','sara','logen','yousra']
for i in range (3):
    print(names[i])


#find the minmal value 
numbers = [12,6,5,20,18,23,2]
def findminimal(numbers):
    min= 99999999
    for i in numbers: 
     if i<min :
        min=i
    print(min)    
    
findminimal(numbers)



#find the maximum value 
numbers = [12,2,5,32,3,6]
max= -99999999
for i in numbers: 
 if i>max :
   max=i
   # 32>12
   # min =32
print(max)    

#Ai chat partner code :
from mblock import event

questions= ['Hello','What is your Name?','How are you?']
answers = ['Hi','My name is Panda','Iam 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+=1
            sprite.say(answers[j],2)    
        else:
            newQuestion=answer
            sprite.say('I do not understand you',2)
            answer = sprite.input('Cloud you teach me')
            if 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