Computer Science 101 Introduction to Programming.

Slides:



Advertisements
Similar presentations
Types and Arithmetic Operators
Advertisements

Fundamentals of Python: From First Programs Through Data Structures Chapter 2 Software Development, Data Types, and Expressions.
Introduction to Python
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
Basic Elements of C++ Chapter 2.
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.
Computer Science 101 Introduction to Programming.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Introduction to Python
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Fundamentals of Python: First Programs
Computer Science 111 Fundamentals of Programming I Overview of Programming.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
Computer Science 101 Introduction to Programming.
Computer Science 111 Fundamentals of Programming I Basic Program Elements.
Sep 12, 2007Sprenkle - CS1111 Objectives Review  Linux  Why programming languages? Compiled vs. Interpreted Languages Programming in Python  Data types.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Variables, Expressions and Statements
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 2 Variables.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
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.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Python Let’s get started!.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Fundamentals of Programming I Overview of Programming
Chapter 2 Variables.
Chapter Topics The Basics of a C++ Program Data Types
Topics Designing a Program Input, Processing, and Output
Chapter 6 JavaScript: Introduction to Scripting
Chapter 1: Introduction to computers and C++ Programming
Chapter 2 Introduction to C++ Programming
Python Let’s get started!.
Introduction to Python
BASIC ELEMENTS OF A COMPUTER PROGRAM
Basic Elements of C++.
Data Types, Identifiers, and Expressions
Revision Lecture
ICS103 Programming in C Lecture 3: Introduction to C (2)
Variables, Expressions, and IO
Introduction to Scripting
Basic Elements of C++ Chapter 2.
Introduction to C++ Programming
Chapter 2 Edited by JJ Shepherd
Chapter 2 Variables.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Terminal-Based Programs
12th Computer Science – Unit 5
Primitive Types and Expressions
Chapter 2 Variables.
Lexical Elements & Operators
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Computer Science 101 Introduction to Programming

From Algorithms to Programs Algorithms are abstract things that can have –Linguistic realizations (in pseudocode or a programming language) –Hardware realizations (in digital circuitry)

What Is a Program? One or more algorithms written in a programming language that can be run on hardware Sometimes called software

What Is a Programming Language? A bit like pseudocode, but very strict syntax rules Examples: FORTRAN, COBOL, Lisp, Basic, C, C++, Java, Python, …

From Algorithms to Hardware Algorithm Program Circuitry Translate by human being Translate by compiler

The Program Development Process Editor Compiler Circuitry Program in programming language Program in machine language InputOutput Syntax errors

Python Free, general purpose programming language Can run code interactively in a shell Can also edit and run longer code segments called scripts or programs

Pattern of Simple Programs Get inputs from the user Run an algorithm on these inputs Print the results as outputs

Basic Elements: Variables Variable names - a sequence of letters and/or digits, can include _ (the underscore) Case sensitive - radius and Radius name two distinct variables Variables are usually spelled with lowercase letters, constants with uppercase letters

Assignment Statement Gives a variable a value Variables must have values before they are used in expressions PI = 3.14 area = PI * 6 ** 2 print area = = means set

Basic Elements: Keywords Keywords are special names reserved for special purposes print, if, else, while, import, … Color coded in orange in IDLE

Functions Run a computation on a given value to produce a new value The given values are called arguments >>> abs(-45) 45 >>> round(3.1416, 3) (, …, )

Numeric Data Types int - whole numbers, such as 45, 100, -20 float - numbers with a decimal point, such as 3.14, , -0.33

Arithmetic Operators +, -, *, /, %, ** Evaluate from left to right, but do ** first, the *, /, %, then +, - Use parentheses to override the standard order of evaluation / and % produce integer quotient and remainder with two int s, or a float when at least one operand is a float

Numerical Input The user is prompted with a text message The sequence of keystrokes is converted to an int or a float length = input("Enter the length: ") width = input("Enter the width: ") = input( ) input is a function

String Data Type Use " or ' as delimiters for simple strings Use """ as delimiters for multiline strings or comments """ File: rectangle.py Author: Ken """ length = input("Enter the length: ")

Output Statements print outputs numbers or strings Outputs a newline by default print "My name is Ken" print "I have 15 students" print

Output Statements Use a comma to print several data values on the same line, separated by a space name = "Ken" number = 15 print "My name is", name print "I have", number, "students"

Input of Text (Strings) The user is prompted with a text message The sequence of keystrokes is converted to a single string name = raw_input("Enter your name: ") color = raw_input("Enter your hair color: ") = raw_input( ) raw_input is a function

For Monday Homework due!