Download presentation
Presentation is loading. Please wait.
Published byAdela Hubbard Modified over 9 years ago
1
Some More Python Please ensure that you’re logged on and ready to start
2
Hi! Welcome back to the IT Crowd
3
Please open up Python IDLE
4
Loops do just what they say in the title, repeat programs over and over and never end! Try: while 1 == 1: print(“Over and over, looping out of control!”) Loops do just what they say in the title, repeat programs over and over and never end! Try: while 1 == 1: print(“Over and over, looping out of control!”) What you write Exercise Warm up - Loops = Explanation Don’t copy!
5
print "Welcome to Python!" What you write A quick recap Welcome to Python What appears
6
question= “What\’s your name?” print(question) answer= input() (insert name here) print=(“ You\’re called ” + answer + “ ?”) question= “What\’s your name?” print(question) answer= input() (insert name here) print=(“ You\’re called ” + answer + “ ?”) What you write An exercise from last time In review
7
>>> print("You\'re called " + answer + " ?") You're called Nathaniel ? >>> print("You\'re called " + answer + " ?") You're called Nathaniel ? What you should see What should appear In review
8
Lesson Todays
9
Introduction Operators - Maths Maths in Python works much like Maths in real life. You’ll need your Python maths for when you’re making your games in a few lessons so, don’t forget the basics and enjoy some of the more interesting tasks we have today Maths
10
Try some of these: x = 2 y = 3 z = 5 x * y x + y x * y + z (x + y) * z Try some of these: x = 2 y = 3 z = 5 x * y x + y x * y + z (x + y) * z What you write Exercise Operators - Maths = Explanation Don’t copy!
11
How powers work: 2**8 256 How powers work: 2**8 256 What you write Exercise Operators - Maths = Explanation Don’t copy!
12
Odd or even, this script will react to print what the number is: number = float(input(“Feed me a number: ")) if number % 2 == 0: print(int(number), "is even.") elif number % 2 == 1: print(int(number), "is odd.") else: print(number, "is very strange.”) (Keep repeating and try different numbers!) Odd or even, this script will react to print what the number is: number = float(input(“Feed me a number: ")) if number % 2 == 0: print(int(number), "is even.") elif number % 2 == 1: print(int(number), "is odd.") else: print(number, "is very strange.”) (Keep repeating and try different numbers!) What you write Odd or Even? Operators - Maths = Explanation Don’t copy!
13
number = 7 guess = -1 count = 0 print("Guess the number!") while guess != number: guess = int(input("Is it... ")) count = count + 1 if guess == number: print("Yay! You guessed right!") elif guess < number: print(“Keep guessing, bit bigger…") elif guess > number: print(“Thats way too big, try going lower”) if count > 3: print(“Took you a while but you got there.") else: print(“Hats off to you, clever clogs!”) number = 7 guess = -1 count = 0 print("Guess the number!") while guess != number: guess = int(input("Is it... ")) count = count + 1 if guess == number: print("Yay! You guessed right!") elif guess < number: print(“Keep guessing, bit bigger…") elif guess > number: print(“Thats way too big, try going lower”) if count > 3: print(“Took you a while but you got there.") else: print(“Hats off to you, clever clogs!”) What you write Guess the number Operators - Maths = Explanation Don’t copy! It’s long but interesting. Have a go guessing with the person next to you!
14
name = input('Your name: ') if name == 'Ada': print('That is a nice name.') elif name == ‘Your friend': print(‘something bad about their name') elif name == ‘Another friend: print(‘Be imaginative') else: print('I don’t like your name') name = input('Your name: ') if name == 'Ada': print('That is a nice name.') elif name == ‘Your friend': print(‘something bad about their name') elif name == ‘Another friend: print(‘Be imaginative') else: print('I don’t like your name') What you write Nice name or not? Operators - Maths = Explanation Don’t copy!
15
This will calculate your number, if its bigger than or less than 100 it will show messages. number1 = float(input('1st number: ')) number2 = float(input('2nd number: ')) if number1 + number2 > 100: print('That is a big number.’) else: print(‘That is a small number!’) (Keep repeating and try different numbers!) This will calculate your number, if its bigger than or less than 100 it will show messages. number1 = float(input('1st number: ')) number2 = float(input('2nd number: ')) if number1 + number2 > 100: print('That is a big number.’) else: print(‘That is a small number!’) (Keep repeating and try different numbers!) What you write Adding and printing Operators - Maths = Explanation Don’t copy!
16
Thanks for coming, to keep updated: : @BittTeam Or visit http://itcrowd.gweb.iohttp://itcrowd.gweb.io GIMP After the holidays
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.