Printing in Python. Printing Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external.

Slides:



Advertisements
Similar presentations
/ 251 Internet Applications Ahmed M. Zeki Sem – / Chapter 8.
Advertisements

Getting Input in Python Assumes assignment statement, typecasts.
This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
Python Basics: Statements Expressions Loops Strings Functions.
Classes  All code in a Java program is part of a class  A class has two purposes  Provide functions to do work for the programmer  Represent data.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C Programming
Μαθαίνοντας Python [Κ4] ‘Guess the Number’
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
Files in Python The Basics. Why use Files? Very small amounts of data – just hardcode them into the program A few pieces of data – ask the user to input.
Files in Python Input techniques. Input from a file The type of data you will get from a file is always string or a list of strings. There are two ways.
Introduction to C Programming
1 Character Strings and Variables Character Strings Variables, Initialization, and Assignment Reading for this class: L&L,
Basic Elements of C++ Chapter 2.
CSC1015F – Python Chapter2 Michelle Kuttel
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
2 $ command Command Line Options ls –a –l hello hi Command Arguments.
CTEC 1863 – Operating Systems Shell Scripting. CTEC F2 Overview How shell works Command line parameters –Shift command Variables –Including.
Lists in Python.
Functions Part I (Syntax). What is a function? A function is a set of statements which is split off into a separate entity that can be used like a “new.
Introduction to Computational Linguistics Programming I.
CPTR 124 Review for Test 1. Development Tools Editor Similar to a word processor Allows programmer to compose/save/edit source code Compiler/interpreter.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
Computer Science 111 Fundamentals of Programming I Basic Program Elements.
Scheme & Functional Programming. ( ) >> 64 ( ) >> 666 (* ) >> 1200 (+ (* 3 5) (- 10 6)) >> 19.
Console Input & Output CSS 161: Fundamentals of Computing Joe McCarthy 1.
Input, Output, and Processing
Chapter 1 Working with strings. Objectives Understand simple programs using character strings and the string library. Get acquainted with declarations,
Strings The Basics. Strings can refer to a string variable as one variable or as many different components (characters) string values are delimited by.
Computer Science 101 Introduction to Programming.
For. for loop The for loop in Python is more like a foreach iterative-type loop in a shell scripting language than a traditional for conditional loop.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Introduction to Programming with RAPTOR
Exam 1 Review Instructor – Gokcen Cilingir Cpt S 111, Sections 6-7 (Sept 19, 2011) Washington State University.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Variables, Expressions and Statements
CMSC 202 Java Console I/O. July 25, Introduction Displaying text to the user and allowing the user to enter text are fundamental operations performed.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Files in Python Output techniques. Outputting to a file There are two ways to do this in Python – print (more familiar, more flexible) – write (more restrictive)
Strings See Chapter 2 u Review constants u Strings, concatenation and repetition 1.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
2. WRITING SIMPLE PROGRAMS Rocky K. C. Chang September 10, 2015 (Adapted from John Zelle’s slides)
Operating System Discussion Section. The Basics of C Reference: Lecture note 2 and 3 notes.html.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 2 (Tuesday)
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Simple Console Output. What we will briefly discuss System.out.println( … ) System.out.print( … ) System.out.printf( … )
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 3: Built-in functions.
A Sample Program #include using namespace std; int main(void) { cout
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 10: Files.
arithmetic operator & cin I.Mona Alshehri The output formatting functions setw(width) setw(n) - output the value of the next expression in n columns.
FILE I/O: Low-level 1. The Big Picture 2 Low-Level, cont. Some files are mixed format that are not readable by high- level functions such as xlsread()
Fundamentals of Programming I Overview of Programming
C++ First Steps.
Chapter Topics The Basics of a C++ Program Data Types
Arithmetic Expressions Function Calls Output
Introduction to Programming
Introduction to Python
Basic Elements of C++.
Basic Elements of C++ Chapter 2.
CSS 161 Fundamentals of Computing Introduction to Computers & Java
Introduction to C++ Programming
Lists in Python.
Strings and Lists – the split method
“If you can’t write it down in English, you can’t code it.”
Functions Taken from notes by Dr. Neil Moore & Dr. Debby Keen
Presentation transcript:

Printing in Python

Printing Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files used for output The function used in Python is print. It can have as many arguments as you wish Syntax: print ( arguments ) The argument list can use variables, expressions, constants The argument list can also be empty print()

Semantics of print When the print function is called, it evaluates the arguments and displays them on the shell window It displays them starting wherever the cursor is at the time If there is more than one argument, there will be one space put between them on the screen When it finishes displaying them, it will output a “newline” character (also called a carriage return) This moves the cursor to the left side of the screen and down to the next line. print() is one way to output just a newline character

Extra arguments for print To give the programmer a little more control over the exact positioning of the outputs, there are some extra arguments you can use in the parentheses end= will specify what the print function should output when the list of arguments to output is finished sep= will specify what should be put in between the arguments to separate them (note that this is just between arguments, not at the end of the line) These have string values Example: print(“abc”, “def”, sep=“++”) outputs abc++def on one line

Example of end= print(“joe”, end=“ “ ) that’s a space between the quotes Would output joe on the screen wherever the cursor was at that time and then a space and then the cursor would stay on that line. It would NOT move to the next line.