Thursday, 21 January 2016
13 Comecocos (aleatorial)
# 13 COMECOCOS (aleatorial)
import random
a=0
while a<1:
print ('A number from 1 to 7')
print ('')
answerNumber = input()
def getAnswer(answerNumber):
if answerNumber == 1:
return('Tidy up your bedroom')
elif answerNumber == 2:
return('Help with the laundry')
elif answerNumber == 3:
return('Call your best friend')
elif answerNumber == 4:
return('Write a poem')
elif answerNumber == 5:
return('Don´t think for 2 minutes')
elif answerNumber == 6:
return ('Dance crazily for 2 minutes')
else:
print ('That is not a valid number, you poo!!!!')
r= random.randint (1,7)
fortune = getAnswer(r)
print (fortune)
print ('')
Thursday, 14 January 2016
Tuesday, 12 January 2016
24 My Tables III (ad infinitum)
#Multiplication tables
#With input
#Non stop
a = int(input("Enter a number: "))
b = a
a = 0
while a > -1:
a = a + int(b)
print (a)
#With input
#Non stop
a = int(input("Enter a number: "))
b = a
a = 0
while a > -1:
a = a + int(b)
print (a)
Monday, 11 January 2016
17 Can a bot be aleatorial?
# Import the modules
import sys
import random
import time
print ('Can a bot be aleatorial?')
ans = True
while ans:
answers = random.randint(1,9)
if answers == 0:
sys.exit()
elif answers == 1:
print ('1')
time.sleep(1)
elif answers == 2:
print ('2')
time.sleep(1)
elif answers == 3:
print ("3")
time.sleep(1)
elif answers == 4:
print ("4")
time.sleep(1)
elif answers == 5:
print ("5")
time.sleep(1)
elif answers == 6:
print ("6")
time.sleep(1)
elif answers == 7:
print ("7")
time.sleep(1)
elif answers == 8:
print ("8")
time.sleep(1)
elif answers == 0:
print ("0")
time.sleep(1)
elif answers == 8:
print ("8")
time.sleep(1)
elif answers == 9:
print ("9")
time.sleep(1)
import sys
import random
import time
print ('Can a bot be aleatorial?')
ans = True
while ans:
answers = random.randint(1,9)
if answers == 0:
sys.exit()
elif answers == 1:
print ('1')
time.sleep(1)
elif answers == 2:
print ('2')
time.sleep(1)
elif answers == 3:
print ("3")
time.sleep(1)
elif answers == 4:
print ("4")
time.sleep(1)
elif answers == 5:
print ("5")
time.sleep(1)
elif answers == 6:
print ("6")
time.sleep(1)
elif answers == 7:
print ("7")
time.sleep(1)
elif answers == 8:
print ("8")
time.sleep(1)
elif answers == 0:
print ("0")
time.sleep(1)
elif answers == 8:
print ("8")
time.sleep(1)
elif answers == 9:
print ("9")
time.sleep(1)
16. While
count = 0
while (count < 9):
print ('I repeat this'), count
count = count + 1
print ('"Good bye!')
while (count < 9):
print ('I repeat this'), count
count = count + 1
print ('"Good bye!')
15 The Cashier script (with time.sleep)
#1 Let´s import a toy that we will use later
import time
#2 Print and wait 1 second and print and...
print ('What would you like to eat, sir/madam?')
print (' ')
time.sleep(2)
print ('We have:')
time.sleep(2)
print ('First course:')
print (' Soup, paella, spaghetti and elf_cream')
print (' ')
time.sleep(4)
print ('Second course:')
print (' Meat_balls, Chicken_wings and elf_eyes')
print (' ')
time.sleep(4)
print ('Dessert:')
print (' Ice_cream, icy_tea, elf_nostrils')
print (' ')
time.sleep(4)
print (' Type what you wish')
time.sleep(2)
print ('for example: Soup + Meatballs + Icy_tea. Don´t forget the capital letter')
time.sleep(2)
print ('Then click ENTER')
#3 Now tell Python your prices:
Soup = 5.34
Paella = 6.32
Spaghetti = 5.37
Elf_cream = 60.00
Meat_balls = 8.45
Chicken_wings = 4.20
Elf_eyes = 7.00
Ice_cream = 3.73
Icy_tea = 2.80
Elf_nostrils = 10.20
import time
#2 Print and wait 1 second and print and...
print ('What would you like to eat, sir/madam?')
print (' ')
time.sleep(2)
print ('We have:')
time.sleep(2)
print ('First course:')
print (' Soup, paella, spaghetti and elf_cream')
print (' ')
time.sleep(4)
print ('Second course:')
print (' Meat_balls, Chicken_wings and elf_eyes')
print (' ')
time.sleep(4)
print ('Dessert:')
print (' Ice_cream, icy_tea, elf_nostrils')
print (' ')
time.sleep(4)
print (' Type what you wish')
time.sleep(2)
print ('for example: Soup + Meatballs + Icy_tea. Don´t forget the capital letter')
time.sleep(2)
print ('Then click ENTER')
#3 Now tell Python your prices:
Soup = 5.34
Paella = 6.32
Spaghetti = 5.37
Elf_cream = 60.00
Meat_balls = 8.45
Chicken_wings = 4.20
Elf_eyes = 7.00
Ice_cream = 3.73
Icy_tea = 2.80
Elf_nostrils = 10.20
2squared
a = 2
while a < 10000000000000000000000000000000000000000000000000000:
a = a * a
print (a)
#Change the 2, and compare
27. Count the letters
print ('Copy and paste a text here:')
text = input ()
a = 0
while a < 10:
print ('Choose the letter of letter group you want to count')
letter = input ()
a = text.count(letter)
print (a)
text = input ()
a = 0
while a < 10:
print ('Choose the letter of letter group you want to count')
letter = input ()
a = text.count(letter)
print (a)
Subscribe to:
Posts (Atom)