Input and Output Upsorn Praphamontripong CS 1110

Slides:



Advertisements
Similar presentations
Chapter 2: Input, Processing, and Output
Advertisements

CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
INLS 560 – V ARIABLES, E XPRESSIONS, AND S TATEMENTS Instructor: Jason Carter.
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.
CS 127 Writing Simple Programs.  Stages involved  Analyze the problem  Understand as much as possible what is trying to be solved  Determine Specifications.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
1 © 2000 John Urrutia. All rights reserved. Qbasic Constructing Qbasic Programs.
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
Lesson 6. Python 3.3 Objectives. In this lesson students will learn how to output data to the screen and request input from the user. Students will also.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
COMP 171: Data Types John Barr. Review - What is Computer Science? Problem Solving  Recognizing Patterns  If you can find a pattern in the way you solve.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
Introduction to Computer Programming
Variables and Assignment CSIS 1595: Fundamentals of Programming and Problem Solving 1.
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.
2. WRITING SIMPLE PROGRAMS Rocky K. C. Chang September 10, 2015 (Adapted from John Zelle’s slides)
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
CHAPTER 2 PART #3 C++ INPUT / OUTPUT 1 st Semester King Saud University College of Applied studies and Community Service CSC1101 By: Fatimah.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Variables, Types, Expressions Intro2CS – week 1b 1.
Chapter 2 Writing Simple Programs
C++ First Steps.
Writing algorithms Introduction to Python.
Topics Designing a Program Input, Processing, and Output
Chapter 2 Basic Computation
Introduction to Programming
Python: Experiencing IDLE, writing simple programs
Lesson 1 - Sequencing.
1-1 Logic and Syntax A computer program is a solution to a problem.
Chapter 2: Input, Processing, and Output
Chapter 2 - Introduction to C Programming
Lesson 1 An Introduction
Design & Technology Grade 7 Python
Algorithm and Ambiguity
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Variables, Expressions, and IO
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2 - Introduction to C Programming
Algorithm and Ambiguity
Imperative Programming
Introduction to C++ Programming
Programming Right from the Start with Visual Basic .NET 1/e
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Introduction to Programming
“If you can’t write it down in English, you can’t code it.”
Hello World! Syntax.
Introduction to Algorithms and Programming
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Variables T.Najah Al_Subaie Kingdom of Saudi Arabia
Rocky K. C. Chang September 18, 2018 (Based on Zelle and Dierbach)
Algorithm and Ambiguity
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Inputs and Variables Programming Guides.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Chapter 2: Input, Processing, and Output
12th Computer Science – Unit 5
Introduction to Programming
Chopin’s Nocturne.
Chapter 1 c++ structure C++ Input / Output
Starter Which of these inventions is: Used most by people in Britain
CS 1111 Introduction to Programming Spring 2019
Imperative Programming
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Input and Output Upsorn Praphamontripong CS 1110 Introduction to Programming Spring 2017

Program Development Cycle review Program Development Cycle Design the program Write the code Correct syntax errors Test the program Correct logic errors Understand the task the program will perform Break down the task into a series of steps Algorithm Translate an algorithm into code Two Representation Pseudocode Flowchart CS 1110

Algorithm  Pseudocode review Algorithm  Pseudocode Exercise: Get 2 numbers from the user and display the larger number Algorithm: Get the first number Get the second number Compare the 2 numbers Display the larger number Pseudocode: Input the first number Input the second number If the first number > the second number, display the first number Otherwise, display the second number (what if the first number is equal to the second number?) CS 1110

Algorithm  Flowchart Exercise: review Algorithm  Flowchart Exercise: Get 2 numbers from the user and display the larger number Start Input the first number Algorithm: Get the first number Get the second number Compare the 2 numbers Return the larger number Input the second number the first number is greater than the second number Yes No Display the first number Display the second number End CS 1110

Input – Process – Output Exercise: Get 2 numbers from the user and display the larger number Input Process Output Check if the first number is greater than the second number The first number The larger number The second number input() function print() function CS 1110

Reading Input from the Keyboard input(prompt) input(“What is your name? ”) Display the string “What is your name? ” on the screen Wait for the user to enter something and press Enter The user’s input is returned as a string name = input(“What is your name? ”) The user’s input is returned as a string and assigned to the variable name CS 1110

Variables A name that represents a value stored in the computer’s memory Creating variables with assignment statements statement = "Python is awesome!!!!" Python is dynamic typed language statement = "Python is awesome!!!!” statement = 4 Assignment operator statement Python is awesome String literal Type: string Numeric literal Type: int Variable reassignment CS 1110

Variable Naming Rules No Python’s key words No spaces First character must be one of the letters (a…z or A…Z) or an underscore character ( _ ) Case sensitive Descriptive Consider t (or x) vs temp vs temperature How about payrate vs pay_rate vs payRate CS 1110

Displaying Output on the Screen print(zero or more parameters) print(“Hello World”) Display the string “Hello World” on the screen print(“Hello ” + ”World”) print(“Hello”, ”World”) print() Display an empty line How about print(print())? CS 1110

Strings and String Literals String = a sequence of characters E.g., “Hello World” String literal = a value/string that appears in a program, the actual value of the thing it represents E.g., print(“Hello World”) Must be surrounded by quotation marks Quotation marks used print("Python is awesome!") print('Python is awesome!') print('"Python is awesome!"') print('Python\'s awesome!') CS 1110