Computer Science 1 Online time for Graphics Program Random review

Slides:



Advertisements
Similar presentations
Summer 2012 Instructor: Hassan Khosravi
Advertisements

Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax
10 ThinkOfANumber program1July ThinkOfANumber program CE : Fundamental Programming Techniques.
Lecture 15 Practice & exploration Subfunctions: Functions within functions “Guessing Game”: A hands-on exercise in evolutionary design © 2007 Daniel Valentine.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
Georgia Institute of Technology More on Creating Classes part 2 Barb Ericson Georgia Institute of Technology Oct 2005.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Designing While Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Truth and while Today 15 Minutes online time to finish the random/Swing programs. Truth tables: Ways to organize results of Boolean expressions. Note Taking:
Program Options: 10 Minutes online Write a program that will display your home address as it would on an envelope. –First Name Last Name –Address –City,
Iterative Structures (Loops) CS 1401 Spring 2013 Shirley Moore, Instructor February 28, 2013.
Computer Science I: Understand how to evaluate expressions with DIV and MOD Random Numbers Reading random code Writing random code Odds/evens/…
AP Java Java’s version of Repeat until.
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
ENGINEERING 1D04 Tutorial 4. What are we doing today? Focus Functions Scope of Variables Returning Values Objects Graphics library Aliasing Events Mouse.
Week of 12/12/16 Test Review.
Program Options: 10 Minutes online
Lecture 4B More Repetition Richard Gesick
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
Control Structure Senior Lecturer
Program options Write a program for one of the following
Review Finish program Graphics Programming
Learning to Program in Python
Introduction to pseudocode
Computer Science And he made a molten sea, ten cubits from the one brim to the other: it was round all about, and his height was five cubits: and.
Computer Science 1 Online time to complete/enhance second repeat program Be able to read and write a program that uses the ‘case’ statement.
More Loops.
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Truth tables: Ways to organize results of Boolean expressions.
Chapter (3) - Looping Questions.
Review Dry Run Taking Names Online time Math is Good
Computer Science 1 Get out your notebook
Computer Science 2 Review the Bubble Sort
flow charts and system diagrams
Introduction to TouchDevelop
Computer Science And he made a molten sea, ten cubits from the one brim to the other: it was round all about, and his height was five cubits: and.
Computer Science 2 Getting an unknown # of …. Into an array.
Dry run Fix Random Numbers
Program Options: 10 Minutes online
Truth tables: Ways to organize results of Boolean expressions.
Repeat Day2 Dry Run Second Repeat Program
Loop Strategies Repetition Playbook.
Computer Science 1 Warm-up: True/False Dry Run
Truth tables: Ways to organize results of Boolean expressions.
For loops Taken from notes by Dr. Neil Moore
How can you make a guessing game?
Computer Science II Second With files.
Continue with Life, Magic and Catch -up
Computer Science 2 More Trees.
Computer Science 1 while
Computer Science 1 For..do loop Dry Run Take notes on the For loop
Warm-up: Dry Run DIV / MOD 2nd If Then Program
How can you make a guessing game?
Warm-up: True/False Dry Run DIV / MOD 2nd If Then Program
Computer Science I: Get out your notes.
Computer Science 1 10/16/2018.
WEEK 8 COURSE PROJECT PRESENTATION NAME: ALEXANDER WEISS CLASS: CIS115.
Program options Write a program for one of the following
10/27/2016 Dry Run 2 Case Programs Fix it Second Case Program
Random Numbers while loop
Computer Science 1 while
Computer Science 1 Get out your notebook
Computer Science 1 Get out your notebook
Dry Run Fix it Write a program
Chapter 13 Conditional Repetition
Computer Science And he made a molten sea, ten cubits from the one brim to the other: it was round all about, and his height was five cubits: and.
A bit of Review Review, Dry Run, Program.
GCSE Computing.
Computer Science Club 1st November 2019.
Presentation transcript:

Computer Science 1 Online time for Graphics Program Random review How can you make a guessing game?

Some Pascal Graphics Commands Some Commands SetColor(Integervariable); Circle(x, y, radius); ClearViewPort; //Like clearscreen Outtext(x, y, ‘String you will show on the screen’); Line(x1, y1, x2, y2); Lineto(x,y); Putpixel(x, y, ColorValue); Rectangle(x1, y1, x2, y2); Ellipse(x, y, Start Degrees, End Degrees, Horizontal Radius, Vertical Radius); Colorvariable:=getpixel(x, y);

Today Graphics program Inside circle program: Open and modify the graphy1.pas program from the class website. Today Graphics program Face Stick figure House Inside circle program: Input: The (x,y) coordinate and center of a circle. Also the (x2,y2) coordinates of another point Output: Whether or not the point is inside the circle. (Hint: Use the distance formula) Push: In addition, show this graphically Intersecting circles program: Input: x, y and radius for two circles. Output whether or not the circles intersect. Push: Add graphics

Learning Objectives Be able to write a program that will be able to repeat an unknown number of times.

Random Review 1) random(6)+1 2) random(14)+2 3) random(7)-4

Write the line of code to generate the following ranges of values

Guessing game What do you need to be able to do?

Repeat..until When Semantics When you want to repeat something an unknown number of times and at least once. Semantics Initialize variable (Pick the number the other person needs to guess) Repeat Get/calculate variable (Make a guess) Do all the other stuff you want to repeat (Have the timer ticking, tell them if the guess is too high or too low, etc.) Until variable = flag (They guessed correctly)

Syntax Repeat Until (condition); {All the commands to be repeated} It will repeat until the condition is true. If the condition is false when it gets to the until line, it will repeat again.

Dry run sample program dryRunRepeat; var a,b,c:integer; begin b:=1; c:= a + 2*b; writeln(a:6, b:6, c:6); a:= a + c div b; until (a>25); end.

Program options Guessing game. Implement the guessing game, but also include showing how many guesses it took the user to guess the number. The computer picks a number (1-100) and you guess it. The computer needs to tell you if your guess is high or low. When you guess it correctly, the computer shows how many guesses it took. Push: Write a program where the computer guesses the number you enter. Make this as efficient as possible without cheating. Ulam’s conjecture: If you take any positive integer greater than one. If it is even you divide it by two, if it is odd, you multiply it by 3 and add 1. When you continue this process, you will eventually get down to 1. Write a program to verify or disprove this conjecture.