ENGINEERING 1D04 Tutorial 1. WELCOME! What we’re doing today Who am I How to do well What are computer programs Software Development Cycle Pseudo Code.

Slides:



Advertisements
Similar presentations
Computer Programming w/ Eng. Applications
Advertisements

Introduction to C Programming
CSE202: Lecture 2The Ohio State University1 Variables and C++ Data Types.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Programming Concepts (Part A) Ping Hsu. What is a program? WHITE CAKE RECIPE 1.Preheat oven to 350 degrees F (175 degrees C). 2.Grease and flour a 9x9.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Introduction to C Programming
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Introduction to Python
General Programming Introduction to Computing Science and Programming I.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Input, Output, and Processing
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Variables and Expressions CMSC 201 Chang (rev )
C++ Programming: Basic Elements of C++.
CSE1222: Lecture 2The Ohio State University1. mathExample2.cpp // math example #include using namespace std; int main() { cout
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Python Conditionals chapter 5
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.
Debugging, Escape Command, More Math. It’s your birthday!  Write a program that asks the user for their name and their age.  Figure out what their birth.
Python Let’s get started!.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
1 nd Semester Module2 C# Basic Concept Thanawin Rakthanmanon Computer Engineering Department Kasetsart University, Bangkok.
Python Basics  Values, Types, Variables, Expressions  Assignments  I/O  Control Structures.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
A Sample Program #include using namespace std; int main(void) { cout
Input, Output and Variables GCSE Computer Science – Python.
2.3 Output Formatting. Outputting Format Specify the number of spaces, “c”, used to print an integer value with specifier %cd, e.g., %3d, %4d. E.g. printf.
ENGINEERING 1D04 Tutorial 2. What we’re doing today More on Strings String input Strings as lists String indexing Slice Concatenation and Repetition len()
CMSC201 Computer Science I for Majors Lecture 05 – Comparison Operators and Boolean (Logical) Operators Prof. Katherine Gibson Prof. Jeremy.
Bill Tucker Austin Community College COSC 1315
CMSC201 Computer Science I for Majors Lecture 05 – Comparison Operators and Boolean (Logical) Operators Prof. Katherine Gibson Based on slides by Shawn.
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Introduction to Computing Science and Programming I
Topics Designing a Program Input, Processing, and Output
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Introduction to Python
Lecture 2: Static Methods Expressions reading: 1.4 – 2.1
Presented By S.Yamuna AP/IT
Variables, Expressions, and IO
Introduction to C++ October 2, 2017.
Variables, Printing and if-statements
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Engineering Innovation Center
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
INPUT & OUTPUT scanf & printf.
Introduction to C++ Programming
Programming Funamental slides
Building Java Programs
Rocky K. C. Chang September 18, 2018 (Based on Zelle and Dierbach)
Topics Designing a Program Input, Processing, and Output
Building Java Programs
Introduction to Programming with Python
Lecture 2: Static Methods Expressions reading: 1.4 – 2.1
Topics Designing a Program Input, Processing, and Output
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
Topics Designing a Program Input, Processing, and Output
Other types of variables
Winter 2019 CISC101 4/28/2019 CISC101 Reminders
Unit 3: Variables in Java
Data Types and Maths Programming Guides.
COMPUTING.
Introduction to Python
Building Java Programs
Presentation transcript:

ENGINEERING 1D04 Tutorial 1

WELCOME!

What we’re doing today Who am I How to do well What are computer programs Software Development Cycle Pseudo Code vs. Code Variables Getting Input from a User Python as a Calculator Expressions/Literals Comments Print Statement For loop/range function Practice!

Important Info! Who am I? Rachel Lim Just completed third year of Electrical and Biomedical Eng Have TAd for five terms so far, this is my sixth Love to travel

How to Succeed Practice, practice, practice! Attend lectures, tutorials and labs Practice before major labs

WHAT IS A COMPUTER PROGRAM? Think “Recipe”

Software Development Process Analyze the Problem Determine Specifications Create a Design Implement the Design Test/DebugMaintenance

Coding Pseudo Code Step 1: Gather Ingredients Step 2: Preheat Oven to 350 F Step 3: Mix Dry Ingredients Step 4: Mix Wet Ingredients Step 5: Combine Wet and Dry Step 6: Bake for 20 minutes Actual Code oven = 350 wet = “milk” + “eggs” dry = “flour + “sugar” mix = wet+dry cookies = string(oven) + mix print cookies

Variables/Elements A name for a space to hold information The names are case sensitive Should have some context Names are called identifiers or variables Must begin with a letter or underscore

Variables Names Good X Temp Count Velocity Speed height Bad xhgjeo !jigjrejgi A,b,c,d,e,f,g (using letters as all of your variable names can become confusing) for, in, print (reserved words for python – already have another function)

Variable Types int: plain integers > 3 long: long integers >3L double: floating point numbers >3.0 complex: real and imaginary part numbers >3+4i string: sequence of characters > hello bool: Boolean (True or False) type() will tell you what type of variable it is

Built in Functions abs() : gives you the absolute value of a number abs(-3) = 3 round() : rounds a floating-point number to the nearest integer round(1.2) = 1 int() and float() and string() will change what’s in brackets to its own type int(1.2) = 1, float(1) = 1.0, string(1) = “1”

Assigning Variables Correct format: X = 3 So the variable name will be on the LHS with the assigned value on the RHS after an equal sign You can also assign two values to two variables in one line: x,y = 3,4 How would you swap two values? x,y = y,x

Getting input from a user Say we would like to ask the user for a number We can use the function “input” Ex. x= input(“please enter a number: ”)

Using Python as a Calculator + - / % * ** Remember BEDMAS applies!

Integer Division When you divide two integers, the answer can be given as a quotient and a remainder Ex. 26/10 quotient: 2 remainder: 6 When Python divides, only the quotient will be given as the answer Ex. 26/10 = 2  This is known as Integer Division How do we avoid this? Make sure both numbers aren’t integers: 26., 26.0 and/or 10., 10.0 Ex. What will the result be if we type in 95/100?

Expressions and Literals Expressions: something that produces or calculates a new value ie. x=3+5 Literal: something that represents a specific value ie. 3

Comments Every time you code you should leave comments! Comments help other people understand your code In Python, comments begin with a # This means that Python will ignore anything coming after this symbol

Print We use print to output values onto the screen Successive print statements will print on different lines Blank print statements will print blank lines You can use a comma to print multiple values on the same line

Definite Loop and Range Function A loop that will run for a specified number of times Takes the format for in : Range is a function that will return a list of numbers REMEMBER! It always starts at zero

What will each do? Python Demo Range(6) Range(1,6) Range(4,-1) Range(1,5,2)

Practice Quadratic Formula Solve: x 2 -x+6=0 And print it

Practice for Major 1