Monday, 29 September 2014

SIRI Program

This is the code we used for Siri:






#Siri!!


#Restart
restart = 'y'
while restart=='y':

#Importing modules
 import random
 import time

 #Get users name
 user_name = input("\nWhat is yor name?\n")

 #Write answers.

 ans1= "Sure Thing"
 ans2= "Why not"
 ans3= "Siri Aproves"
 ans4= "HaHa Nice!"
 ans5= "Go for it"
 ans6= "So Cool!"
 ans7= "I'm Siri"
 ans8= "Cool Story"
 print ("Hi",user_name)
 print ("Meet Siri.")


 #Creates a random wait between shaking.
 wait1=random.randint(1,8)
 wait2=random.randint(1,8)
 wait3=random.randint(1,8)
 wait4=random.randint(1,8)
 wait5=random.randint(1,8)



  #get the users questions.
 question= input ("Ask me for advice then press ENTER to shake me?\n")


 #Shaking with a random wait time.
 print ("Shaking...\n")
 time.sleep(wait1)
 print ("Shaking...\n")
 time.sleep(wait2)
 print ("Shaking...\n")
 time.sleep(wait3)
 print ("Shaking...\n")
 time.sleep(wait4)




 #Create a dice.
 choice=random.randint(1,8)
 if choice==1:
    answer=ans1
 elif choice==2:
    answer=ans2
 elif choice==3:
    answer=ans3
 elif choice==4:
    answer=ans4
 elif choice==5:
    answer=ans5
 elif choice==6:
    answer=ans6
 elif choice==7:
    answer=ans7
 else:
    answer=ans8

#Print answer to the screen

 print ("You asked -", question)
  time.sleep(wait5)
 print("Siri says -",answer)
 restart= input("\n\n Enter y to to play again\n")

Saturday, 20 September 2014

Wednesday, 17 September 2014

5 Times Table




This is how i made IDLE do the 5 times table:
number=5
while number<=100:
    print(number)
    number=number+5









Restart = y




We used:
restart='y'
while restart == 'y':
    
    print("i love computer science.\n"*2)

    restart =input("would you like to play again? (y/n)")


To make repeat when you answer "y".
    
                   

Monday, 15 September 2014

Loops

We made IDLE do 50 lines of I love computer science. using a while loop:
lines=0
while lines<50:
print ("i love computer science")
lines = lines+1

You can also use:
print("i love computer science.\n" *50)
Or:
Lines=50
while line>1:
print ("i love computer science")
lines=lines-1



Saturday, 13 September 2014

Maths

We used addition,subtraction,multiply and assign. First we set the variables a,b. then we changed them.

Wednesday, 10 September 2014

Hello World




I made IDLE say Hello World using the code:print ("hello world")





 I then learnt how to  use back slashes and astrixes.
We then learnt how to do calculations:


Sunday, 7 September 2014

Code Academy

 In today's lesson I completed 6% of the python course on www.codeacademy.com which included variables,booleans and . mathematics