GCSE Computing.

Slides:



Advertisements
Similar presentations
Microsoft® Small Basic
Advertisements

Controlled Assessment
James Tam Loops In Python In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
1 Random numbers Random  completely unpredictable. No way to determine in advance what value will be chosen from a set of equally probable elements. Impossible.
10 ThinkOfANumber program1July ThinkOfANumber program CE : Fundamental Programming Techniques.
Chapter 4: Looping CSCI-UA 0002 – Introduction to Computer Programming Mr. Joel Kemp.
Hands on Projects Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
Control Structures FOR Statement Looping.
MOM! Phineas and Ferb are … Aims:
Chapter 5 Repetition or loop structure. What is repetition or loop? repeat the execution of one or a group (block; instruction enclosed in a pair of braces)
Python Repetition. We use repetition to prevent typing the same code out many times and to make our code more efficient. FOR is used when you know how.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Counter-Controlled Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Loops Wrap Up 10/21/13. Topics *Sentinel Loops *Nested Loops *Random Numbers.
Make a dice challenge! This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.Copy the code below in.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Loops and Simple Functions CS303E: Elements of Computers and Programming.
Copyright © Curt Hill Loop Types and Construction Logical types and construction hints.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Count Controlled Loops (Nested) Ain’t no sunshine when she’s gone …
Intro to Loops 1.General Knowledge 2.Two Types of Loops 3.The WHILE loop 1.
Loops and Simple Functions COSC Review: While Loops Typically used when the number of times the loop will execute is indefinite Typically used when.
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.
Repetition In today’s lesson we will look at: why you would want to repeat things in a program different ways of repeating things creating loops in Just.
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
Computer Programming 12 Lesson 6 – Loop structure By: Dan Lunney.
Chapter 6 Functions The Tic-Tac-Toe Game. Chapter Content In this chapter you will learn to do the following: 0 Write your own functions 0 Accept values.
26/06/ Iteration Loops For … To … Next. 226/06/2016 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Objective of the lesson Use Blockly to make a dice for Snakes and Ladders All of you will: – Make an image which displays when you press a button Most.
Loops & More 1.Conditionals (review) 2.Running totals and Running products 3.the for loop, examples 4.Nesting for loops, examples 5.Common errors 1.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 23, 2005 Lecture Number: 11.
GCSE COMPUTER SCIENCE Practical Programming using Python
Trace Tables In today’s lesson we will look at:
Dice Game Pseudocode Module main() Declare String reply
Recap: If, elif, else If <True condition>:
Repetition Structures
Week of 12/12/16 Test Review.
Lesson 4 - Challenges.
Lesson 3 - Repetition.
Review If you want to display a floating-point number in a particular format use The DecimalFormat Class printf A loop is… a control structure that causes.
Starter Write a program that asks the user if it is raining today.
Writing Functions( ) (Part 5)
Java for Beginners University Greenwich Computing At School DASCO
Introduction to pseudocode
More Loops.
More Loops.
Class 14 functions in Python can return multiple values counting loops
Chapter (3) - Looping Questions.
Design and Implementation
Repetition Structures
Module 4 Loops.
Topics Introduction to Repetition Structures
3.1 Iteration Loops For … To … Next 18/01/2019.
Nested Loops & The Step Parameter
Let’s all Repeat Together
Introduction to Repetition Structures
Flowcharts and Pseudo Code
CSCI N207 Data Analysis Using Spreadsheet
GCSE Computing:: While Loops
Hint idea 2 Split into shorter tasks like this.
int [] scores = new int [10];
Learning Intention I will learn about the standard algorithm for input validation.
GCSE Computing Mini Assignment.
Iteration – While Loops
GCSE Computing.
GCSE Computing.
Computer Science Club 1st November 2019.
Presentation transcript:

GCSE Computing

Random Numbers Dice game – generate two random numbers and add them together. Import random – required as this module contains code that allows the random number generator to work, saves us time to add extra code. random.randint(1,6) random no 1-6 random.randrange(6) + 1 random no 1-6

Dice add game import random die1 = random.randint(1,6) die2 = random.randrange(6)+1 total = die1 + die2 print(“total scored :”, total) input(“\n\nPress enter key to continue”) We will return to develop this code later.

While loop y Again variable again =“y” while again != “n”: line1 line2 line3 etc. again = input(“Would you like to repeat? [y/n]”) This loop will repeat lines 1-3 until the user enters n. The criteria for the loop could change e.g. while total !=7:

While Loop (Condition controlled Loop) Write a mini program that prints the following two lines and then loops to repeat if the user selects y. This is my first independent use of the While loop It’s not really that difficult!!! Would you like to view again? [y/n] Once you are happy that this works include a While Loop into your dice game program to allow the user to play again.

Times Tables Using While Loop Using the While Loop run a program that prints out the times table for a number of your choice up to 12. For example the 5 times table should display like this: 5 10 15 20 25 30 35 ….. etc. 60 end

Times Tables Using While Loop n = 0 while n < 65: print (n) n += 5 How could you use this code to find out if a particular number is a multiple of your chosen multiplication table? E.G. does 3 go into 972

For loop (Count Controlled Loop) for i in range (0,5): print(“Looping”) #this will repeat the print code 5 times. Create a program that outputs the word computing 15 times.

For loop (Count Controlled Loop) for i in range (0,5): print(i, “Looping”) #this will include the variable i inside the loop Create a program that asks for a number then outputs it’s times table. E.g. 1 times 7 is 7 2 times 7 is 14…etc.