Pick a number, any number …

Slides:



Advertisements
Similar presentations
Building Java Programs
Advertisements

HW 1: Problems 3 & 4 EC 1 & 2.
Main task -write me a program
Chapter 4: Looping CSCI-UA 0002 – Introduction to Computer Programming Mr. Joel Kemp.
Lecture 15 Practice & exploration Subfunctions: Functions within functions “Guessing Game”: A hands-on exercise in evolutionary design © 2007 Daniel Valentine.
An Introduction to Textual Programming
Control Structures FOR Statement Looping.
MOM! Phineas and Ferb are … Aims:
 We are going to learn about programming in general…How to think logically and problem solve. The programming language we will use is Python. This is.
More on Functions (Part 2) Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
COSC 1306—COMPUTER SCIENCE AND PROGRAMMING PYTHON BRANCHES AND LOOPS Jehan-François Pâris
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.
Logical Operators, Boolean Variables, Random Numbers This template was just too good to let go in one day!
Number lines, fractions and knowing where you are.
More on Functions Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Coding Time This is a starter activity and should take about 10 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.Start a script session (Select.
Georgia Institute of Technology More on Creating Classes part 1 Barb Ericson Georgia Institute of Technology Oct 2005.
Design of Rock-Paper-Scissors end Print instructions Play game Ask user If (s)he wants to play again Play again? Y Print stats: wins, losses and ties start.
CSc 110, Spring 2017 Lecture 12: Random Numbers
Recap: If, elif, else If <True condition>:
More on Functions (Part 2)
Repetition Structures
Building Java Programs
Building Java Programs
Building Java Programs Chapter 5
Building Java Programs
Python Random numbers Peter Wad Sackett.
Control Structures II Chapter 3
Introduction to Programmng in Python

Building Java Programs
CSc 110, Autumn 2016 Lecture 13: Random Numbers
CS1010 Programming Methodology
Engineering Innovation Center
Brain-storming In your groups come up with a list of 6 of the following: Superheroes Real-life heroes Supervillains Real-life villains.
Writing Functions( ) (Part 5)
Writing Functions( ) (Part 5)
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Bomb’s vs Unicorns.
Building Java Programs
Exception Handling.
Computer Science 1 Online time to complete/enhance second repeat program Be able to read and write a program that uses the ‘case’ statement.
Decision Structures, String Comparison, Nested Structures
Repetition Structures
Learning to Program in Python
flow charts and system diagrams
Building Java Programs
Chapter 5 Loops.
random number between 1 and 5.
Building Java Programs
More on Functions (Part 2)
Python Random numbers Peter Wad Sackett.
Writing Functions( ) (Part 4)
Big problem  small steps
Sunken Treasure The Guessing Game for Treasure on the High Seas.
Console.WriteLine(“Good luck!”);
The first number is posted telling what random number was selected, I did this for testing purposes, in the real thing it would not be there. Since the.
Using the cards – Match up the element’s symbol with its atomic structure.
Building Java Programs
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Sunken Treasure The Guessing Game for Treasure on the High Seas.
Building Java Programs
Formatting Output.
This shows running the first guess number program which only allows one guess - I show the correct answer for testing purposes.
Game Description Player 1: Decides on integer x > 0
Iteration – While Loops
Odds and Evens Here is a set of numbered balls used for a game:
Surveys How to create one.
Presentation transcript:

Pick a number, any number … Random Functions Pick a number, any number …

Random Numbers Python has the ability to generate random numbers We can achieve this using the randint( ) function The randint( ) function takes two arguments as the inclusive boundaries from which to choose a value from, it then returns an integer value at random

Random Numbers However, randint( ) is not a function that is embedded into Python’s main shell Therefore, we need to import a file called “random”, then we can call the specific function from the file

Random Numbers

Practice Define a function that recreates the guessing magic number game but this time, make the magic number randomly generated Make sure the function includes statements for whether the guess was too high or too low

Randomizing Statements It would be kind of weak if we could only generate random integers and that was it We can extend these random integers into randomizing statements and other values

Practice Write a program of my favorite game, the one I used to lure all of you into this class … Recreate the game rock, paper, scissors on Python and have your computer play fair by random!

Practice See if you can recreate the rock paper scissors game to continuously run until the user does not want to play anymore OR until the user wins 5 times OR play best out of 3