Intro to Computer Science CS1510 Dr. Sarah Diesburg

Slides:



Advertisements
Similar presentations
Types and Arithmetic Operators
Advertisements

Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Binary Conversions Number systems Binary to decimal Decimal to binary.
Chapter 1 Beginnings.
Agenda Data Representation – Characters Encoding Schemes ASCII
The character data type char
Introduction to Python
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Numeric Types, Expressions, and Output ROBERT REAVES.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Numerical Representation Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg 1.
CSC 107 – Programming For Science. The Week’s Goal.
Variables, Expressions and Statements
Representing Characters in a computer Pressing a key on the computer a code is generated that the computer can convert into a symbol for displaying or.
ECS 15 Variables. Outline  Using IDLE  Building blocks of programs: Text Numbers Variables!  Writing a program  Running the program.
The character data type char. Character type char is used to represent alpha-numerical information (characters) inside the computer uses 2 bytes of memory.
Data as the computer sees it 1.  Number systems Number systems  Data storage Data storage  Glossary Glossary 2.
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.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
PYTHON VARIABLES : CHAPTER 2 FROM THINK PYTHON HOW TO THINK LIKE A COMPUTER SCIENTIST.
Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Problem Solving Intro to Computer Science CS1510 Dr. Sarah Diesburg 1.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Numerical Representation Intro to Computer Science CS1510 Dr. Sarah Diesburg 1.
CS 100 Introduction to Computing Seminar September 12/14, 2016.
Thinking about programming
Whatcha doin'? Aims: To start using Python. To understand loops.
A Playful Introduction to Programming by Jason R. Briggs
Introduction to Python
CMSC201 Computer Science I for Majors Lecture 22 – Binary (and More)
BASIC ELEMENTS OF A COMPUTER PROGRAM
Numerical Representation
ITEC113 Algorithms and Programming Techniques
Presented By S.Yamuna AP/IT
Variables, Expressions, and IO
Thinking about programming
Building Java Programs Chapter 2
Numerical Representation
2.1 Parts of a C++ Program.
String Encodings and Penny Math
Introduction to Java, and DrJava part 1
Learning Outcomes –Lesson 4
Types, Truth, and Expressions (Part 2)
Intro to Computer Science CS1510 Dr. Sarah Diesburg
T. Jumana Abu Shmais – AOU - Riyadh
Data Representation – Chapter 3
Fundamentals of Data Representation
Presenting information as bit patterns
Plan Attendance Files Posted on Campus Cruiser Homework Reminder
How Computers Store Data
Topics Designing a Program Input, Processing, and Output
Numerical Representation
Introduction to Java, and DrJava
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Beginning Python Programming
Thinking about programming
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Primitive Types and Expressions
Winter 2019 CISC101 4/28/2019 CISC101 Reminders
String Encodings and Penny Math
Introduction to Java, and DrJava part 1
Programming Fundamental-1
Lecture 36 – Unit 6 – Under the Hood Binary Encoding – Part 2
Numerical Representation
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Intro to Computer Science CS1510 Dr. Sarah Diesburg Problem Solving Intro to Computer Science CS1510 Dr. Sarah Diesburg

Your turn #1 What unsigned decimal numbers are represented by the following binary numbers? Example: 00000101 = 5 10100111

Your turn #2 How would you write the following numbers in binary? Example: 14 = 8 + 4 + 2 -> 00001110 3 121 143

Encoding Binary numbers can represent more things than just integers Another example is ASCII American Standard Code for Information Interchange Character encoding scheme based on the English alphabet http://en.wikipedia.org/wiki/ASCII

Tomorrow’s lab Make sure you are answering the question asked and answering them completely/accurately Decimal points When I ask you to predict I mean it. I won’t mark you off for being wrong so don’t fake your “prediction” Try to be as clear as possible in your written answers Start bringing your textbooks to lab

Getting Started Install Python Navigate to your programs Launch IDLE http://www.python.org Install version 3 (NOT version 2) Navigate to your programs Launch IDLE (Integrated DeveLopment Environment) Default environment packaged with Python

Two IDLE environments Interpreter – this is what you see first Using numerical literals Using variables and formulas Try things in here! Scripting – click on File -> New File To write and save code into programs Click Run -> Run Module to run code

Base Mathematical Operators addition : + subtraction: - multiplication: * division quotient: / Integer quotient: // remainder: % exponentiation: ** (do not use ^)

Literals Literal is a programming notation for a fixed value. For example, 123 is a fixed value, an integer it would be “weird” if the symbol 123’s value could change to be 3.14!

Number literals By default, IDLE assumes that anything without a decimal is an integer. > 2 2 > -5 -5 By default, IDLE assumes that anything with a decimal is a floating point number. > 3.5 3.5 > -4.0 -4.0

But we don’t often work with JUST literals… Normally when we do calculations we want to store the calculations to use later: To do this we need to store values associated with a name (a variable) A variable is a name we designate to represent “something” in our program We use names to make our program more readable, so that the “something” is easily understood

Python Name Conventions must begin with a letter or _ Ab123 is OK, but 123ABC is not. may contain letters, digits, and underscores this_is_an_identifier_123 may be of any length upper and lower case letters are different LengthOfRope is not lengthofrope names starting with _ have special meaning. Be careful

Variable Objects Name Value X 7 X = 7 Python maintains a list of pairs for every variable: variable’s name variable’s value A variable is created when a value is assigned the first time. It associates a name and a value subsequent assignments update the associated value. we say name references value A variable’s type depends on what is assigned. Name Value X 7 X = 7

When = Doesn’t Mean Equal It is most confusing at first to see the following kind of expression: myInt = myInt + 7 You don’t have to be a math genius to figure out something is wrong there. What’s wrong is that = doesn’t mean equal

= is assignment In many computer languages, = means assignment. myInt = myInt + 7 lhs = rhs What “assignment” means is: evaluate all the “stuff” on the rhs of the = take the resulting value and associate it with the name on the lhs

More Assignment Example: x = 2 + 3 * 5 evaluate expression (2+3*5): 17 change the value of x to reference 17 Example (y has value 2): y = y + 3 evaluate expression (y+3): 5 change the value of y to reference 5