Python.
10 Lovely Smile and 11 Lovely Smile x5
def main():
pass
if __name__ == '__main__':
main()
nice_feature =("Lovely Smile")
name = input("Please enter your name.")
print((name,"has a", nice_feature, )*5)
12 Enter your name.
name = input("Please enter your name.")
print((name+"\n") *5)
13 Calculation.
num= int(input("Please enter a 3 digit number."))
whole = (num/7)
wholeinteger =int(num)
remainder = num%7
print("Whole number is",whole, "\nWhole integer is",wholeinteger, "\nRemainder is:", remainder )
14 Password
username=(input("Please enter username"))
if username =="Cat":
print("Your username is correct")
else:
print ("Your username is incorrect")
password=(input("Please enter password"))
if password == "Tosca":
print("You have succesfully logged in")
else:
print("Password are incorrect")
15 Odd or Even
number=int(input("Please enter a number"))
y = number%2
if y == 0:
print("That's Even")
else:
print("That's Odd")
print("Thanks for playing")
16 Timetable Challenge
z = int(input("Please enter the times table you wish to see"))
for x in range (z,z*12+z,z):
print (x)
17 Alternative Timetable
for n1 in range (1,13):
for n2 in range(1,13):
print(n1,"x",n2, "=", n1*n2)
n=input("Press enter to continue")
18 While Loop
x= 0
y= 0
while x <10:
x=x+1
y=x**2
print(x,"Squared=", y)
print("Thanks")
19 Menu
c=0
while c!= 9:
menu=("What do you want to know?:\n\
1- Next week's lottery winner's\n\
2- The Secret of life\n\
9- Exit program\n")
c=int(input("Please enter your choice"))
if c == 1:
print("Next weeks lottery winner is Cat!!!")
elif c == 2:
print("The Secret to like is the number 42")
elif c == 9:
print("Exit and Goodbye")
20 Menu for Random Sample
import random
def Lottery():
print("The lottery numbers are:")
print(random.sample(range(1,59), 6))
#Long way for lottery Numbers.
#num1=random.randrange(1,59)
#num2=random.randrange(1,59)
#num3=random.randrange(1,59)
#num4=random.randrange(1,59)
#num5=random.randrange(1,59)
#num6=random.randrange(1,59)
# print("The lottery numbers are:",num1, num2, num3, num4, num5, num6)
def Mol():
print("The meaning of life is 42.")
c=0
while c!= 9:
menu=("What do you want to know?:\n\
1- Next week's lottery winner's\n\
2- The Secret of life\n\
9- Exit program\n")
c=int(input("Please enter your choice"))
if c == 1:
Lottery()
elif c == 2:
Mol()
elif c == 9:
print("Exit and Goodbye")
Teaching Ideas.
Agbonline Teaching Exercises.
Using python.com
20 code Challenges( complete for GCSE 9-1 )
Python Exercises.
Introduction to Python
Python exercises