Thursday, 4 February 2016

Count For Me. with intervals



#count for me
numbers = range(0,288,10)
for count in numbers:
     print (count)

     #changing the numbers?
     #adding three inputz?

Creating a .py file




#Let´s repeat previous lesson. We are going to create a Python document call test.py. We will use it for experimenting.

#Open Python
#File > New > Save > test.py
#Close Python
#Find test.py > right click > IDLE Editor
#Try it out, copy this.

a = 7
print (a)


#Click F5
#Say Yes to Save
#Position the two windows comfortably (IDLE on left, the Shell on right)
 

#Done! You are now ready for more challenging stuff.

While

#Playing with while

#while 1
a=0
while a<1:
   print ('.............................................')

#while 2
a=1
while a <1000:
    a=a+1
    print (a)

#while3
a=1
while a <1000:
    a=a-1
    print (a)

If



#In this script we are going to ask a closed question (three options of answer). The user with read the question and answer. Depending on the answer, the script will reply with a specific comment. 

print ('Do you believe in God?')
a = input ( )

if a == ('yes'):
    print ('You are a believer')
elif a == ('no'):
    print ('You are either an agnostic or an atheist')
else:
    print ('No wanna talk with me? Bye!')

input ( )



#Input 1. Copy and paste these 3 lines. Then click F5.
print ('Whatz your name')
a = input ( )
print (a)

#Input 2. Try these 3.
print ('Whatz your name')
a = input ( )
print ('Nice to meet you, ' + a)


#Input 3. More:
print ('Whatz your name')
a = input ( )
print ('Nice to meet you, ' + a)
print ('How old are you')
b = input ( )
print ('So, you are ' + a + ' and you are ' + b + ' years old')


#Input 4. Your turn

Variables



#Open test.py (previous lesson).
Remember: right-click > open with IDLE
You are going to use it for testing little snippets of code.

# Variables 1: Copy and paste the following two lines. Then click F5.
a = 7
print (a)

What is happening?

# Variables 2: Delete the previous. Try these three now. Then click F5.
a = 9
b =a
print (b)

# Variables 3: What is happening? Now a longer one.
a = 9
b = a
c = b
d = c
e = d
print (d)

#Variables 4: With input (varying answers)
print ('You favourite word')
a = input ( )
print ('Your favourite word is ' + a)

What is happening?

#Variables 5: With 2 different inputs:
print ('You favourite word')
a = input ( )
print ('You favourite number')
b = input ( )
print ('So you like ' + a + b)

#Variable 6: Your turn. Create more!


Squared iii (with input)

print ('Choose a number for me to square')

a = int(input ())

while a < 10000000000000000000000000000000000000000000000000000:

    a = a * a

    print (a)

Wednesday, 3 February 2016

Monday, 1 February 2016


















































Comecocos

a=0
while a<1:
    print ('A number from 1 to 6')
    print ('')
    guess = int(input())

    if guess  == 1:
        print('Tidy up your bedroom')
        print ('')

    elif guess == 2:
        print('Help with the laundry')
        print ('')

    elif guess == 3:
        print('Call your best friend')
        print ('')
     

    elif guess == 4:
        print('Write a poem')
        print ('')

    elif guess == 5:
        print('Don´t think for 2 minutes')
        print ('')
       
    elif guess == 6:
        print('Dance crazily for 2 minutes')
        print ('')

    else: print ('That is not a valid number, you poo!!!!')











































































Guess The Number



# This is a guess the number game.

import random
secretNumber = random.randint(1, 20)
print('I am thinking of a number between 1 and 20. You have 6 chances')

# Ask the player to guess 6 times.
for guessesTaken in range(1, 7):
    print('Take a guess.')
    guess = int(input())
    if guess < secretNumber:
        print('Your guess is too low.')
    elif guess > secretNumber:
        print('Your guess is too high.')
    else:
        break # This condition is the correct guess!


if guess == secretNumber:
    print('Good job! You guessed my number in ' + str(guessesTaken) + ' guesses!')
else:
    print('Nope. The number I was thinking of was ' + str(secretNumber))

Which Numbers Between

#WhichNumbersBetween
a=int(input("Starting Number"))
b=int(input ("Finishing Number"))
for i in range (a , b):
    print (i)    #python

Add Numbers to 100

#AddNumbersTo100
total = 0
for num in range (101):
      total = total + num                       
      print (total) #python

How Fast Can You Count

#HowFastCanYouCount
a = 1
while a > 0:
    a = a+1
    print (a)    #python

James Bond Password (Extended)



a = ' '
while a != 'JamesBond':
    print ('username')
    a = input ( )

b = ' '
while b != '007':
    print ('password')
    b = input ( )

print ('Welcome to MI6')



James Bond Password



a = '   '

while a != '007':
    print ('password')
    a = input ()
print ('Welcome to M16')