Walk through previous lecture. TSP Questions: How many tours are there? How do you solve it? How fast can you solve it?

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

This is Java Jeopardy.
Strings An extension of types A class that encompasses a character array and provides many useful behaviors Chapter 9 Strings are IMMUTABLE.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Datalogi A 3: 26/9. Java Concepts chapter 4 Fundamental Data Types int (long and short) double (and float) boolean char String.
Geography 465 Assignments, Conditionals, and Loops.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Python Control of Flow.
Chapter 9 IF Statement Bernard Chen. If Statement The main statement used for selecting from alternative actions based on test results It’s the primary.
4. Python - Basic Operators
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
Introduction to Computational Linguistics Programming I.
Programming in Python Part I Dr. Fatma Cemile Serçe Atılım University
Strings CS303E: Elements of Computers and Programming.
Building Java Programs Primitive Data and Definite Loops.
TA Office Hours Tue: 10am – 11am, TBA. Walk through previous lecture.
Primitive data Week 3. Lecture outcomes Primitive data – integer – double – string – char – Float – Long – boolean Declaration Initialisation Assignments.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Python Conditionals chapter 5
“Great leaders are never satisfied with current levels of performance. They are restlessly driven by possibilities and potential achievements.” – Donna.
By Austin Laudenslager AN INTRODUCTION TO PYTHON.
Last Week Modules Save functions to a file, e.g., filename.py The file filename.py is a module We can use the functions in filename.py by importing it.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
3 Basics © 2010 David A Watt, University of Glasgow Accelerated Programming 2 Part I: Python Programming.
1 CS 177 Week 6 Recitation Slides Review for Midterm Exam.
COMP 110: Spring Announcements Lab 1 due Wednesday at Noon Assignment 1 available on website Online drop date is today.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
More Python Proglan Python Session 2. Lists  Lists are like flexible arrays. They can contain as many variables as you wish, and all variable types are.
© 2007 Pearson Addison-Wesley. All rights reserved2-1 Character Strings A string of characters can be represented as a string literal by putting double.
PYTHON VARIABLES : CHAPTER 2 FROM THINK PYTHON HOW TO THINK LIKE A COMPUTER SCIENTIST.
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
Expressions and Order of Operations Operators – There are the standard operators: add, subtract, divide, multiply – Note that * means multiply? (No times.
Python Basics  Values, Types, Variables, Expressions  Assignments  I/O  Control Structures.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Control flow Ruth Anderson UW CSE 160 Winter
Introduction to Programming Oliver Hawkins. BACKGROUND TO PROGRAMMING LANGUAGES Introduction to Programming.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Python Basics.
Introduction to Calculated Columns Variables, Conditionals, and String Manipulation PRESENTER: Cameron Blashka| Informer Implementation Specialist| April.
Introduction to Python
G. Pullaiah College of Engineering and Technology
Key Words / Reserved Words
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
Basic operators - strings
Ruth Anderson UW CSE 160 Winter 2017
Control flow : if statements
Introduction to Programming Using Python PART 2
Introduction to Python
Lecture 2 Python Programming & Data Types
Nate Brunelle Today: Conditional Decision Statements
Chapter 2 Programming Basics.
Python Basics with Jupyter Notebook
Introduction to Python
The Data Element.
Nate Brunelle Today: Conditional Decision Statements
Winter 2019 CISC101 4/28/2019 CISC101 Reminders
The Data Element.
Comparing Python and Java
Nate Brunelle Today: Conditional Decision Statements
Class code for pythonroom.com cchsp2cs
CMPT 120 Lecture 10 – Unit 2 – Cryptography and Encryption –
Python Basics. Topics Features How does Python work Basic Features I/O in Python Operators Control Statements Function/Scope of variables OOP Concepts.
Primitive Data Types and Operators
COMPUTING.
Building Java Programs
Presentation transcript:

Walk through previous lecture

TSP Questions: How many tours are there? How do you solve it? How fast can you solve it?

how to run a python program $ python hello.py

Functions in print >>> print "hello" + "world" # concatenation helloworld >>> print len("helloworld") # length 10 >>> print "hello".upper() # upper case HELLO >>> print "HELLO".lower() # lower case hello >>> print str(3.14) # string conversion 3.14

Primitive Types NameDescriptionSize intInteger4 bytes floatFloating point number 4 bytes longLong integer4 bytes complexComplex numbers8 bytes

print %d %f %s..

escape sequences \n\r\t\’\”\\..

Arithmetic Operators  Addition (+)  Subtraction (-)  Multiplication (*)  Division (/)  Exponentiation (**)  Modulo (%)

conditions >>> if condition1:... # do this Example: >>> if 8 < 9:... print "I get printed!"

conditions >>> if condition1:... # do this... elif condition2:... # do this Example: >>> if 8 < 9:... print "I get printed!"... elif 8 > 9:... print "I don’t get printed!"

conditions >>> if condition1:... # do this... elif condition2:... # do this... else:... # do this Example:... if 8 < 9:... print "I get printed!"... elif 8 > 9:... print "I don’t get printed!"... else:... print "I also don’t get printed!"

True and True is True True and False is False False and True is False False and False is False True or True is True True or False is True False or True is True False or False is False Not True is False Not False is True Boolean Operators

Boolean expressions >>> if condition1 or condition2:... # do this Example: >>> if 8 > 7 or 8 > 10:... print "I get printed"

Boolean expressions >>> if condition1 and condition2:... # do this Example: >>> if 8 > 7 and 8 > 10:... print "I don’t get printed"

loops >>> for iterating_var in sequence:... # do this again and again Example: >>> for index in range(10):... print index

loops >>> while condition:... # do this again and again Example: >>> while index < 10:... print index

to be continued... Tc = (5/9)*(Tf-32);