elppa legoog erawdrah erawtfos margorp Cisab llams Apple Google

Slides:



Advertisements
Similar presentations
Microsoft® Small Basic
Advertisements

ITEC113 Algorithms and Programming Techniques
1-8 An Introduction to Equations
Bug Session Four. Session description Objectives Session activities summary Resources Prior knowledge of sequencing instructions using Bug Bug website.
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.
CRE Programming Club - Class 4 Robert Eckstein and Robert Heard.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
CRE Programming Club - Class 4 Robert Eckstein and Robert Heard.
Python Lesson 2.
Algorithms and Pseudocode
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
CMSC 104, Version 8/061L05Algorithms2.ppt Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode Control Structures Reading Section 3.1.
JavaScript Controlling the flow of your programs with ‘if’ statements
Learning outcomes 5 Developing Code – Using Flowcharts
5.04 Apply Decision Making Structures
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Repetition Structures Chapter 9
Lesson 4 - Challenges.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Computer Programming I
Unit 2 Smarter Programming.
Introduction to Programmng in Python
The order in which statements are executed is called the flow of control. Most of the time, a running program starts at the first programming statement,
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
UMBC CMSC 104 – Section 01, Fall 2016
Starter Write a program that asks the user if it is raining today.
Microsoft Visual Basic 2005 BASICS
Arrays & Functions Lesson xx
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
Nate Brunelle Today: Pseudo-Code, Party
Microsoft® Small Basic
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Lesson 1: Fundamentals of Programming
2008/09/22: Lecture 5 CMSC 104, Section 0101 John Y. Park
Objectives After studying this chapter, you should be able to:
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Loops CIS 40 – Introduction to Programming in Python
Introduction to TouchDevelop
IPC144 Introduction to Programming Using C Week 3 – Lesson 2
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
CIS 16 Application Development Programming with Visual Basic
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithm and Ambiguity
Chapter 4 Select…Case Multiple-Selection Statement & Logical Operators
Let’s all Repeat Together
ICT Programming Lesson 3:
Software Development Process
Flowcharts and Pseudo Code
ICT Gaming Lesson 2.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
IPC144 Introduction to Programming Using C Week 4 – Lesson 1
Using Decision Structures
Chapter 4: Boolean Expressions, Making Decisions, and Disk Input and Output Prof. Salim Arfaoui.
Basic Lessons 5 & 6 Mr. Kalmes.
Basic Concepts of Algorithm
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
Warm Up Tonight’s Homework: 1-8 Lesson Check(pg 56)
Chapter 3: Selection Structures: Making Decisions
Telling Time to the Nearest Minute
Python Selection.
Review of Previous Lesson
IPC144 Introduction to Programming Using C Week 2 – Lesson 2
Nate Brunelle Today: Pseudo-Code
Module 4 Loops and Repetition 9/19/2019 CSE 1321 Module 4.
Presentation transcript:

elppa legoog erawdrah erawtfos margorp Cisab llams Apple Google Statements, Properties, and Operations Starter – unscramble the words elppa legoog erawdrah erawtfos margorp Cisab llams Apple Google Hardware Software Program Small basic

Questions on variables Friday, November 16, 2018 Homework - Last Week Questions on variables Hand in for marking

Friday, November 16, 2018 Homework - This Week Write your homework in your planner – it’s due next week IF, Else, Elseif, Then & Endif

Microsoft® Small Basic Conditions – IF, Then, Else, Endif Estimated time to complete this lesson: 1 hour

Conditions In this lesson, you will learn how to: Write programs that carry out different instructions based on whether one or more logical conditions are true.

Conditions in Small Basic Programs Recap variables and the read function Let’s look at the following program: This program instructs the computer to ask for your age. Notice that this program contains a variable “myage”. It read the input and remembers what it is. Finally it writes a sentence to the screen that tells you how old you are

Conditions in Small Basic Programs In small basic you can specify conditions that control how your program runs (or whether it runs at all)? Let’s look at the following program: This program uses some of the code from the previous slide but then informs the user which school year they are in.    You use the If keyword to specify a condition that the computer evaluates to determine whether it should perform a particular operation. You use the Then keyword to specify what operation or operations the computer should perform if the condition is true. If the condition is false, the computer skips the operation or operations and proceeds to the next line of the program. You use the EndIf keyword to indicate that the computer should proceed to the next line of the program regardless of whether the condition was true. Notice that this program contains the If, Then and EndIf keywords.

Conditions in Small Basic Programs Using objects to specify conditions to control your program runs Let’s look at the following program: This program instructs the computer to display "Happy New Year" only if today is January 1st.  In Small Basic, you use the Clock object to determine the current date and time.   Code: If Clock.Day = 1 And Clock.Month = 1 Then TextWindow.WriteLine("Happy New Year") EndIf Notice that this program also contains the If, Then, and EndIf keywords.

Conditions in Small Basic Programs Now, let’s write a program in which you specify an alternate action to perform if the condition is false. Depending on when you run the program, the computer displays one of the following results: Code: If Clock.Hour < 12 then TextWindow.WriteLine("Did you have your breakfast?") EndIf If Clock.Hour > 12 then TextWindow.WriteLine("Did you have your lunch?")

Conditions in Small Basic Programs In programming, you can do that same thing in more than one way. As a programmer, you can choose the best way. In this example, you might have noticed that the second condition in the program repeats a lot of information in the first condition. Let’s reduce the repetition by using the Else keyword. In this program, you specify a condition and an operation to perform if that condition is true. Then you specify a second condition and a second operation to perform if the second condition is true. However, the first condition is true only if the second condition is false, and the second condition is true only if the first condition is false. Therefore, you don’t need to specify the second condition because the computer can determine which operation to perform based only on the first condition. Instead of giving the computer two conditions to evaluate, you can specify that the computer should perform the first operation if the first condition is true and the computer should perform the second operation if the first condition is false.   The result of both approaches is the same. This example shows that you can do the same thing in different ways in programming. It’s up to you! Code: If Clock.Hour < 12 Then TextWindow.WriteLine("Did you have your breakfast?") Else TextWindow.WriteLine("Did you have your lunch?") EndIf Both programs give the same result, but you can use fewer If, Then, and EndIf keywords if you use the Else keyword.

Show What You Know Now try to write a program that asks the user their age then if they are older than 18 informs them they should be in school but if they are older than 18 tells them they should be in school. Look at your previous code and use that to help you. The math symbol for more than is > Remember to use the ELSE keyword How did you do? Solution:

Let’s Summarize… Congratulations! Now you know how to: Write programs that evaluate logical conditions and perform operations based on those results.

Consolidate – Exit ticket Friday, November 16, 2018 Consolidate – Exit ticket WWW - One thing you learned today? Or One thing you enjoyed today? EBI – One thing you could do better One thing you will need help with next lesson?