Lecture 1: Introduction; Basic Python Programs

Slides:



Advertisements
Similar presentations
Copyright 2008 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: self-check: #1-14.
Advertisements

Intro to Robots Robots are Everywhere. Intro to Robots Various robots in use today lawnmower pet baby seal for convalescents gutter cleaner home security.
Introduction to Python
Chapter 2 Writing Simple Programs
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 1: Introduction to Java Programming.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
* Note: All of the material for the Required Textbook, Optional Textbook are protected by Copyright Law. * Professor Sana Odeh’s notes and programs listed.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
Copyright 2008 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: self-check: #1-14.
Python.
Introducing Java.
INLS 560 – V ARIABLES, E XPRESSIONS, AND S TATEMENTS Instructor: Jason Carter.
CPTR 124 Review for Test 1. Development Tools Editor Similar to a word processor Allows programmer to compose/save/edit source code Compiler/interpreter.
Programming in C#. I. Introduction C# (or C-Sharp) is a programming language. C# is used to write software that runs on the.NET Framework. Although C#
Building Java Programs Chapter 1 Introduction to Java Programming Copyright (c) Pearson All rights reserved.
CSCI 161: Introduction to Programming 1
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
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!.
Copyright 2010 by Pearson Education CSE 142, Fall 2011 Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Copyright 2010 by Pearson Education CSE 142, Spring 2012 Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: 1.1 -
Welcome to CSE 142! Zorah Fung University of Washington, Summer Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Next Week… Quiz 2 next week: –All Python –Up to this Friday’s lecture: Expressions Console I/O Conditionals while Loops Assignment 2 (due Feb. 12) topics:
CSc 127a/110, Autumn 2016 Lecture 1: Introduction; Basic Python Programs.
Zorah Fung University of Washington, Winter 2016
Chapter 2 Writing Simple Programs
C++ First Steps.
CSc 110, Autumn 2017 Lecture 2: Functions.
Software Development.
Programming what is C++
CMSC201 Computer Science I for Majors Lecture 02 – Intro to Python
Topic Pre-processor cout To output a message.
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Welcome to CSE 142! Whitaker Brand and Benson Limketkai
Python Let’s get started!.
CSCI 161 – Introduction to Programming I William Killian
Structured Programming
CSE 190D, Winter 2013 Building Java Programs Chapter 1
Variables, Expressions, and IO
Statement atoms The 'atomic' components of a statement are: delimiters (indents, semicolons, etc.); keywords (built into the language); identifiers (names.
Algorithm and Ambiguity
SSEA Computer Science: CS106A
Benson Limketkai and Marty Stepp University of Washington, Spring 2010
Introduction to Python
Benson Limketkai University of Washington, Spring 2011
Building Java Programs
Whitaker Brand University of Washington, Winter 2018
Programming Languages 2nd edition Tucker and Noonan
Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t Inserts a tab in the.
Brett Wortzman University of Washington, Summer 2011
Algorithm and Ambiguity
CSc 110, Spring 2018 Lecture 2: Functions.
Building Java Programs
Welcome to CSE 142!.
CSE 142, Summer 2012 Building Java Programs Chapter 1
CISC101 Reminders All assignments are now posted.
Module 2 - Part 1 Variables, Assignment, and Data Types
CSE 142, Spring 2012 Building Java Programs Chapter 1
Lecture 1: Introduction; Basic Python Programs
Zorah Fung University of Washington, Spring 2015
CSE 142, Winter 2014 Building Java Programs Chapter 1
Consult America Technology Consulting Services
Zorah Fung University of Washington, Winter 2016
Chapter 2 part #1 C++ Program Structure
CSC 241: Introduction to Computer Science I
Python Reserved Words Poster
Presentation transcript:

Lecture 1: Introduction; Basic Python Programs CSc 110, Autumn 2017 Lecture 1: Introduction; Basic Python Programs

Course Staff Allison Obourn (aeobourn@cs.arizona.edu) Section Leaders Your primary point of contact Ask them about their experiences in CSc

Computer Science CS is about PROCESS – describing how to accomplish tasks "efficiently implementing automated abstractions" (Philip Guo) Computers are a tool Currently the best implementation platform What kinds of problems can they solve? How can they be made faster, cheaper, more efficient…? Science? More like engineering, art, magic… Hypothesis creation, testing, refinement important CS is still a young field finding itself

Why should you take Computer Science? … like solving tricky problems … like building things … (will) work with large data sets … are curious about how Facebook, Google, etc work … are shopping around for a major 110 is a good predictor of who will enjoy and succeed in CSc

Are you in the right class? CSc 101 Intro to Computer Science CSc 110 Intro to Computer Programming I CSc 120 Intro to Computer Programming I You are here

Programming program: A set of instructions to be carried out by a computer. program execution: The act of carrying out the instructions contained in a program. programming language: A systematic set of rules used to describe computations in a format that is editable by humans.

Some modern languages procedural languages: programs are a series of commands Pascal (1970): designed for education C (1972): low-level operating systems and device drivers functional programming: functions map inputs to outputs Lisp (1958) / Scheme (1975), ML (1973), Haskell (1990) object-oriented languages: programs use interacting "objects" Smalltalk (1980): first major object-oriented language C++ (1985): "object-oriented" improvements to C successful in industry; used to build major OSes such as Windows Python (1991): The language taught in this course

Why Python? Relatively simple Pre-written software Widely used

A Python program Its output: print("Hello, world!") print() print("This program produces") print("four lines of output") Its output: Hello, world! This program produces four lines of output console: Text box into which the program's output is printed.

print A statement that prints a line of output on the console. Two ways to use print : print("text") Prints the given message as output. print() Prints a blank line of output. 10

Strings and escape sequences

Strings string: A sequence of characters to be printed. Restrictions: Starts and ends with a " quote " character or a ' quote ' character. The quotes do not appear in the output. Examples: "hello" "This is a string. It's very long!" 'Here is "another" with quotes in' """I can span multiple lines because I'm surrounded by 3 quotes""" Restrictions: Strings surrounded by " " or ' ' may not span multiple lines "This is not a legal String." Strings surrounded by " " may not contain a " character. "This is not a "legal" String either." Strings surrounded by ' ' may not contain a ' character. 'This is not a 'legal' String either.' 12

Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t tab character \n new line character \" quotation mark character \' quotation mark character \\ backslash character Example: print("\\hello\nhow\tare \"you\"?\\\\") Output: \hello how are "you"?\\

Questions What is the output of the following print statements? print("\ta\tb\tc") print("\\\\") print("'") print("\"\"\"") print("C:\nin\the downward spiral") Write a print statement to produce this output: / \ // \\ /// \\\

Answers Output of each print statement: a b c \\ ' """ C: in he downward spiral print statement to produce the line of output: print("/ \\ // \\\\ /// \\\\\\")

Questions What print statements will generate this output? This quote is from Irish poet Oscar Wilde: "Music makes one feel so romantic - at least it always gets on one's nerves – which is the same thing nowadays." A "quoted" String is 'much' better if you learn the rules of "escape sequences." Also, "" represents an empty String. Don't forget: use \" instead of " ! '' is not the same as "

Answers print statements to generate the output: print("This quote is from") print("Irish poet Oscar Wilde:”) print() print("\"Music makes one feel so romantic") print("- at least it always gets on one's nerves -") print("which is the same thing nowadays.\"") print("A \"quoted\" String is") print("'much' better if you learn") print("the rules of \"escape sequences.\"") print("Also, \"\" represents an empty String.") print("Don't forget: use \\\" instead of \" !") print("'' is not the same as \"")

Keywords keyword: An identifier that you cannot use because it already has a reserved meaning in Python. and del from not while as elif global or with assert else if pass yield break except import print class exec in raise continue finally is return def for lambda try