Xin Liu Jan 30, 2013. * By default, input() read a string from keyboard * This can be changed with an indirection operator ‘<‘ * python3 program.py <

Slides:



Advertisements
Similar presentations
Getting Input in Python Assumes assignment statement, typecasts.
Advertisements

STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
User Input. Why user entry? When we assign values (age = 16), we are making a program static…it never changes. If we ask the user to enter the values,
Arithmetic and Geometric Transformations (Chapter 2) CS474/674 – Prof. Bebis.
Programming in python Lesson 2.
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Data Types. Every program must deal with data The data is usually described as a certain type This type determines what you can do with the data and how.
Computer Science 111 Fundamentals of Programming I Overview of Programming.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 6: Variables and constants.
Java ProgrammingtMyn1 Java Programming Timo Mynttinen Mikkeli University of Applied Sciences.
Computer Science 101 Introduction to Programming.
Xin Liu Feb 11, * Part 1 1. What value does s have, after this code is run? s = '*' s = s + s s = s + s + s (A) '**' (B) '***' (C) '****' (D) '*****'
12.4 – Find Sums of Infinite Geometric Series. Think about this… What will happen when n becomes really big? It will get closer and closer to zero.
PDA Program Install Manual IT Team. 1. Execute Internet Explorer 2. Connect Website 3. Download 4. Installation 5. Run 6. Setting 1. Execute.
COP 3530 Data Structures & Algorithms Discussion Session 3.
9.1 Notes Geometric Mean. 9.1 Notes Arithmetic mean is another term that means the same thing as average. The second do now question could have been,
ALGEBRA II ARITHMETIC & GEOMETRIC MEANS.
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
CPSC 233 Tutorial Xin Jan 24, Assignment 1 Due on Jan 28 at 4:00 PM Part I  Assignment Box on 2 nd floor Part II  Submitted electronically on.
Python Programming Using Variables and input. Objectives We’re learning to use basic knowledge of variables combined with user input. Outcomes Continue.
Xin Liu Feb 4, * Use midterm questions for previous 231/217 midterms for practices * ams
ECS 15 Variables. Outline  Using IDLE  Building blocks of programs: Text Numbers Variables!  Writing a program  Running the program.
Xin Liu Feb 25, * Compared to Arithmetic mean, or average * The Geometric Mean of 2 numbers is defined as.
Computer Science 111 Fundamentals of Programming I Default and Optional Parameters Higher-Order Functions.
Python 101 Dr. Bernard Chen University of Central Arkansas PyArkansas.
Solve by Factoring Zero Product Property.
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
13.3 Arithmetic and Geometric Series and Their Sums Finite Series.
Dictionaries and File I/O George Mason University.
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Warm Up Week 4 ( 2, 5 ) and ( 14, 1 ) 1) What is the midpoint?
Introduction to Programming
Week 5 Warm Up { -3, 8, 19, 30, 41, . . } n = 3 1) tn = 2) tn - 1 =
Fundamentals of Programming I Overview of Programming
Python unit_4 review Tue/Wed, Dec 1-2
Arithmetic and Geometric Means
Data Types and Conversions, Input from the Keyboard
Variables and Expressions
Lesson 4 - Challenges.
Introduction to Python Data Types and Variables
ASSIGNMENT NO.-2.
Do it now activity Green pen activity in books.
Strings in Python Creating a string.
What Is a Program? A program is like an algorithm, but describes a process that is ready or can be made ready to run on a real computer Retrieved from:
Introduction to Python
الكلية الجامعية للعلوم التطبيقية
Java so far Week 7.
Margaret Derrington KCL Easter 2014
Notes Over 11.5 Recursive Rules
Introduction to Programming
Arithmetic Sequences:
Warm up 1. One term of a geometric sequence is a5 = 48. The common ratio is r = 2. Write a rule for the nth term. 2. Find the sum of the geometric.
Appending or adding to a file using python
Programming Dr. Jalal Kawash.
Module 3 Arithmetic and Geometric Sequences
Introduction to Programming
Data Types and Maths Programming Guides.
Put the on A on the keyboard.
Text Copyright (c) 2017 by Dr. E. Horvath
Module 3 Arithmetic and Geometric Sequences
CS 1111 Introduction to Programming Spring 2019
More Basics of Python Common types of data we will work with
Karan Thaker CS 265 Section 001
Python Classes In Pune.
Python Creating a calculator.
Programming for Business Computing Introduction
Presentation transcript:

Xin Liu Jan 30, 2013

* By default, input() read a string from keyboard * This can be changed with an indirection operator ‘<‘ * python3 program.py < datafile.txt nData = int(input()) for i in range(nData): print(input())

* Compared to Arithmetic mean, or average * The Geometric Mean of 2 numbers is defined as

* The Geometric Mean of 3 numbers is defined as

* The Geometric Mean of n numbers is defined as

* Download data files from pages.cpsc.ucalgary.ca/~liuxin * What if the number of floats is zero? nData = int(input()) product = 1.0 for i in range(nData): product = product * float(input()) product = product ** (1/nData) print("The Geometric Mean is: ", product)

* Q & A for Assignment 1