Transition to Code Upsorn Praphamontripong CS 1111

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

CS107 Introduction to Computer Science Lecture 2.
Programming with Microsoft Visual Basic th Edition
Programming TBE 540 Farah Fisher. Objectives After viewing this presentation, the learner will be able to… Given a task, create pseudocode Given pseudocode,
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
 Control structures  Algorithm & flowchart  If statements  While statements.
Chapter 2: Algorithm Discovery and Design
Pseudocode.
Adapted from slides by Marie desJardins
Simple Program Design Third Edition A Step-by-Step Approach
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Invitation to Computer Science, Java Version, Second Edition.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
1 Program Planning and Design Important stages before actual program is written.
Introduction to Problem Solving and Control Statements.
How to Program? -- Part 1 Part 1: Problem Solving –Analyze a problem –Decide what steps need to be taken to solve it. –Take into consideration any special.
Structured Programming The Basics. Control structures They control the order of execution What order statements will be done in, or whether they will.
 Software Development Life Cycle  Software Development Tools  High Level Programming:  Structures  Algorithms  Iteration  Pseudocode  Order of.
1 Overview of Programming Principles of Computers.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Algorithms and Pseudocode
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Pseudocode. Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.
1 Structured Programming Arab Academy for Science and Technology CC112 Dr. Sherif Mohamed Tawfik The Course.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
Chapter 1 – Introduction
Input and Output Upsorn Praphamontripong CS 1110
while Repetition Structure
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
Upsorn Praphamontripong CS 1110 Introduction to Programming Fall 2016
Topics Introduction to Repetition Structures
Programming Mehdi Bukhari.
PROGRAM CONTROL STRUCTURE
Algorithm and Ambiguity
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Transition to Code Upsorn Praphamontripong CS 1110
Chapter 5: Control Structure
Introduction To Flowcharting
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithm and Ambiguity
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Control Structure Senior Lecturer
CPS120: Introduction to Computer Science
Algorithms & Pseudocode
Nate Brunelle Today: PyCharm
3 Control Statements:.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Introduction to Algorithms and Programming
Introduction to Problem Solving and Control Statements
Algorithm and Ambiguity
Understanding Problems and how to Solve them by using Computers
Let’s all Repeat Together
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Creating Computer Programs
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
CS 1111 Introduction to Programming Spring 2019
Flowcharts and Pseudo Code
A LESSON IN LOOPING What is a loop?
ICT Gaming Lesson 2.
CS2011 Introduction to Programming I Selections (I)
EPSII 59:006 Spring 2004.
Introduction to Programming
Creating Computer Programs
WJEC GCSE Computer Science
CHAPTER 6 Testing and Debugging.
Presentation transcript:

Transition to Code Upsorn Praphamontripong CS 1111 Introduction to Programming Spring 2018

review Pseudocode Pseudocode is one of the methods that can be used to represent / describe an algorithm (usually in English) Not use specific programming language syntax Can be easily translated into a high-level programming language Usually include terms specifying a sequence of actions the a program will take CS1111-Spring2018

Control Structures Sequence Condition ( if ) Repetition ( loop ) review Control Structures Sequence A series of statements that execute one after another Condition ( if ) To decide which of the two or more different statements to execute depending on a certain condition Repetition ( loop ) To repeat statements while certain conditions are true Subprogram A small part of another program solving a certain problem CS1111-Spring2018

Control Structures Sequence review Control Structures Sequence A series of statements that execute one after another statement1 statement2 statement3 statement4 … 6 steps walk, walk, walk, walk, walk, walk, right-turn-180-degree, sit CS1111-Spring2018

Control Structures Condition ( if ) review Control Structures Condition ( if ) To decide which of the two or more different statements to execute depending on a certain condition If (condition): statement1 else: statement2 condition statement 1 statement 2 true false …. CS1111-Spring2018

Control Structures Repetition ( loop ) review Control Structures Repetition ( loop ) To repeat statements while certain conditions are true ? steps Repeat until you are in front of the chair, turn, sit while (condition): statement1 statement2 statement3 … condition statement(s) true false …. CS1111-Spring2018

Control Structures Subprogram review Control Structures Subprogram A small part of another program solving a certain problem A collection of subprograms solves the original problem walk walk walk … subprogram A meaningful collection of sequence, conditions, repetitions, and subprograms … CS1111-Spring2018

Activity Imagine you are writing a program that accepts six project scores from the user. All scores are out of 100 points, except the first (which is out of 30) and the fifth (which is out of 50). The program allows a user to specify whether the lowest project score will be dropped. The program then computes and displays the highest average score for the projects. For example, if a user enters Score for project 1 = 15 Score for project 2 = 55 Score for project 3 = 55 Score for project 4 = 55 Score for project 5 = 25 Score for project 6 = 55 With the lowest project score being dropped, the highest average score will be 54 Without the lowest project score being dropped, the highest average score will be 53.33 Reminder: Always check your pseudocode. -- Ambiguity? Does your pseudocode solve the problem? Does it handle the situation when some project scores are missing? Rewrite/revise? CS1111-Spring2018

Revisit Example from Last Meeting Problem: A company is planning to have a storewide sale of 20% Sales tax is 5% You enter the price of an item based on the price tag Calculate the final sale price of an item after applying the discount and the sales tax Display the final sale price Test: Item price = 100, work Item price = 0, not work Item price = -100, not work 1. Get item price 2. Check if price is <= 0, then repeat step 1 3. Apply 20% discount 4. Add 5% sales tax 5. Display final sale price 1. Get item price 2. Apply 20% discount 3. Add 5% sales tax 4. Display final sale price rewrite CS1111-Spring2018

Executable version (.pyc) Python Interpreted programming language code (.py) 1. Get item price 2. Check if price is <= 0, then repeat step 1 3. Apply 20% discount 4. Add 5% sales tax 5. Display final sale price Python interpreter Interpret at runtime (Python 3.6) Executable version (.pyc) CS1111-Spring2018

PyCharm Integrated Development Environment Editor window (“editor”) Project management window (“project view”) Execution window (“console”) CS1111-Spring2018