Posts

Showing posts with the label loops

08/06/16

Image
Learning Objective:   Understand and be able to use loops to iterate in Python 1st.... PE FORM VIDEO  - Iteration classroom.google.com Red Task Error correction - Complete slides 2&3 Amber Task Create 'Guess the number' code - complete slides 5&6 Green Task Use the code in slide 7 to adapt your 'Guess the number' code to include a while loop.

07/12/15

Image
Learning Objective: Understand how to create a loop in Python and use a Boolean variable to define when to stop ITERATION - What is it? What is the process of iteration?  What are the 2 types of iteration?  Who can tell me the difference between these 2 types of iterations?  from random import randint myNumber = randint(1, 100) guessNum = 0 numberGuessed = False guess = 0 print (I’m thinking of a number between 1 and 100…”) print (“Make a guess and I’ll tell you whether the number is higher or lower”) while numberGuessed == False:     guess = int(input(“Enter your guess: “))     guessNum += 1     if myNumber > guess:      print (“Higher”)     elif myNumber < guess:      print (“Lower”)     elif myNumber == guess:      print (“Well done you’ve guessed the number in “ +...