CRE Programming Club Class 2 (Import JJZ543 and Practice Your Typing!)

Slides:



Advertisements
Similar presentations
 Variables  What are they?  Declaring and initializing variables  Common uses for variables  Variables you get “for free” in Processing ▪ Aka: Built-in.
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Variables – the Key to Programming. ICS-3M1 - Mr. Martens - Variables Part 1 What is a Variable? A storage location that is given a “name” You can store.
Week 2: Primitive Data Types 1.  Programming in Java  Everything goes inside a class  The main() method is the starting point for executing instructions.
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
Session 5 of 10 Review + Multiple Sprites
Introduction to Primitives. Overview Today we will discuss: –The eight primitive types, especially int and double –Declaring the types of variables –Operations.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
A simple program: Area of a circle Problem statement: Given the radius of a circle, display its area Algorithm: 4. Display area To store values, we need.
Methods: a first introduction Two ways to make tea: 1: boil water; put teabag into cup;... etc : tell your younger brother: makeTea(1 milk, 0 sugar);
CHAPTER 3: CORE PROGRAMMING ELEMENTS Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
110-D1 Variables, Constants and Calculations(1) Chapter 3: we are familiar with VB IDE (building a form…) to make our applications more powerful, we need.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
Introduction to Python
Week 2 - Monday.  What did we talk about last time?  Software development  Lab 1.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
Unit 3: Java Data Types Math class and String class.
Input, Output, and Processing
VARIABLES & CONSTANTS. Objective By the end of the lesson students should be able to:  Define a constant  Define a variable  Understand the rules for.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Collecting Things Together - Lists 1. We’ve seen that Python can store things in memory and retrieve, using names. Sometime we want to store a bunch of.
Welcome to the CRE Programming Club! Robert Eckstein and Robert Heard.
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Variables Damian Gordon. Variables We know what a variable is from maths. We’ve all seen this sort of thing in algebra: 2x – 10 = 0 2x = 10 X = 5.
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)
VARIABLES Programmes work by manipulating data placed in memory. The data can be numbers, text, objects, pointers to other memory areas, and more besides.
CRE Programming Club Class 3 (Install Small Basic on the new computers! Double-click on I:/smallbasic.msi)
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
CRE Programming Club - Class 2 Robert Eckstein and Robert Heard.
Variables and Expressions CMSC 201. Today we start Python! Two ways to use python: You can write a program, as a series of instructions in a file, and.
1 Homework Done the reading? –K&R –Glass Chapters 1 and 2 Applied for cs240? (If not, keep at it!) Gotten a UNIX account? (If not, keep at it!)
Python Let’s get started!.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
CS12230 Introduction to Programming Lecture 6-2 –Errors and Exceptions 1.
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
CS112 Scientific Computation Department of Computer Science Wellesley College Storing Values for Safe Keeping Variables and their Values.
Adding 2-digit numbers with regrouping. Always add the ones place first
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
CRE Programming Club - Class 3 Robert Eckstein and Robert Heard.
2.1 First C Program. First Program Open visual studio, click new file Save as “programName.c” – Program must start with letter and have no spaces – Must.
Topics Designing a Program Input, Processing, and Output
Chapter 2 Basic Computation
Introduction to Computer Science / Procedural – 67130
Variables and Primative Types
Variables, Expressions, and IO
Variables, Printing and if-statements
Intro to PHP & Variables
Chapter 2 Basic Computation
Number and String Operations
Introduction to TouchDevelop
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Unit 3: Variables in Java
Lexical Elements & Operators
Presentation transcript:

CRE Programming Club Class 2 (Import JJZ543 and Practice Your Typing!)

Constants and Variables What’s a variable? What’s a constant?

Constant or Variable? How sleepy you are? How many hands you have? The color of your eyes? How big the school is? What color shoes you’re wearing? How many eyes you have? The color of your hair? How many sides a triangle has? How hungry you are? The position of the sun in the sky? The temperature outside?

Variables Variables vary (change), and constants are constantly the same. In the world of programming, there are values in your program that need to change all the time, and there are values that will stay the same. For the most part in Small Basic, you’ll be using variables.

Variables How do we create a variable in Small Basic? Well, we just give it a name and set it equal to something. A = 20 This is kind of like getting a box, writing “A” on the outside, and putting the number 20 inside of it. If you come along later and say, “Hey, I’d like to use what’s in A, you’re going to get 20.” At this point in the program, A = 20.

Variables Let’s test that out by adding the following line afterwards: TextWindow.WriteLine(“A is “ + A) This command will write out the current value of A. What happens if we put the following after it? A = 21 TextWindow.WriteLine(“A is “ + A)

How Programs Run Small Basic programs will read in one line at a time, and execute (run) the code on that line. Program run one line at a time. Programs can jump around if they need to, but we’ll look at that later. At the first TextWindow.writeLine() instruction, A is 20. On the next, A is 21.

Variable Names The name for a variable can be almost any mix of letters, digits, and the character _ (called "underscore"); the only exception is that it cannot begin with a digit. Small Basic doesn't worry about UPPER and lower case. The names AREA, area and Area all refer to one and the same variable.

What Can a Variable Store? So what can a variable store? Well, with Small Basic, one of two things. We already know it can store a number. For those of you working with fractions and decimals, variables can store any number, including those with decimals. So, 40 and a half would be written as 40.5.

Variables Can Also Store Words! Hmmm… how do computers handle words? Well, kind of like what you did as a baby with building blocks. Remember that computers are dumb and they really, really love codes. Turns out the computer has a code number for each letter, a code number for a space, a code number for a questions mark, and, well… a code number for pretty much everything on your keyboard.

What Can a Variable Store? When it wants to use words, it just strings the letters and symbols together like the building blocks of a baby. And, when it’s done, it adds on a special code that says, “Okay, this is the end of the it!” So, we know about numbers, but what are these words or sets of words or symbols or whatever called?

Strings! Let’s write a string and assign it to a variable. A = “Hello There” Note that a string is always surrounded by double quotes. What if we write: A = Hello There

You Can All Sorts of Things With Variables A = “Hello There” A = A = * 4 A = B A = A + 1 A = (B * C) / D A = Math.PI A = Math.PI * R * R A = currentArea - 1 A = “Hello “ + “There” A = “12” + “34” A = “Hello “ + 12

Adding Strings and Numbers What happens if we add two numbers together? What happens if we add a number to a string? A = “Hello” A = A + “ There ” A = A + 12 Try it!

Import VXD019 We’re missing a line that defines the variable kelvin. The formula for converting a temperature to Kelvin is to simply add to the Celsius temperature. Add the line that is needed so that the program runs without causing an error!

Import RTW796-5 This is your first homework assignment. Create three variables that are the radius, circumference, and area of a circle, given the diameter. Use the TextWindow.WriteLine() command to print out the results. Questions? Send me an at

Next Time.... We’re going to learn about objects!