Review.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Getting Input in Python Assumes assignment statement, typecasts.
EasyGUI “Probably the Easiest GUI in the world”. Assumptions (Teachers’ Notes) This resources sets out an introduction to using easyGUI and Python
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
Begin Java having used Alice Pepper - Some slides from Alice in Action with Java.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
THE BIG PICTURE. How does JavaScript interact with the browser?
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Course A201: Introduction to Programming 11/04/2010.
Dynamic Web Pages & JavaScript. Dynamic Web Pages Dynamic = Change Dynamic Web Pages are web pages that change. More than just moving graphics around.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
ProgLan Python Session 4. Functions are a convenient way to divide your code into useful blocks, allowing us to: order our code, make it more readable,
Math, Data Types. Python Math Operations OperationOperator Addition + Subtraction – Multiplication * Division (floating point) / Division (integer) //
Passing Arguments, Local/Global Variables Writing Functions( ) (Part 2)
Count Controlled Loops Look at the little children … Why is the sun’s face features orange …
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.
Formatting Output. Line Endings By now, you’ve noticed that the print( ) function will automatically print out a new line after passing all of the arguments.
Python Let’s get started!.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
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,
Introduction Chapter 1 1/22/16. Check zyBooks Completion Click on the boxes for each section.
Exception Handling and String Manipulation. Exceptions An exception is an error that causes a program to halt while it’s running In other words, it something.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
CSx 4091 – Python Programming Spring 2013 Lecture L2 – Introduction to Python Page 1 Help: To get help, type in the following in the interpreter: Welcome.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
A little PHP. Enter the simple HTML code seen below.
1 Project 12: Cars from File. This is an extension of Project 11, Car Class You may use the posted solution for Project 11 as a starting point for this.
Math, Data Types. Python Math Operations OperationOperator Addition + Subtraction – Multiplication * Division (floating point) / Division (integer) //
Few More Math Operators
A little PHP.
Whatcha doin'? Aims: To start using Python. To understand loops.
Exercise : Write a program that print the final price of purchase at a store where everything costs exactly one dollar. Ask for the number of items purchased.
Python Let’s get started!.
Introduction to Python
Data Types and Conversions, Input from the Keyboard
Formatting Output.
COMP 170 – Introduction to Object Oriented Programming
Chapter 2 - Introduction to C Programming
Introduction to Computer Science / Procedural – 67130
What to do when a test fails
Variables, Expressions, and IO
Formatting Output.
Chapter 2 - Introduction to C Programming
Keyboard Input and Screen Display ––––––––––– Interactive Programming
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Chapter 2 - Introduction to C Programming
INPUT & OUTPUT scanf & printf.
Let’s get some practice!
Introduction to TouchDevelop
Remembering lists of values lists
Writing Functions( ) (Part 4)
Writing Functions( ) (Part 4)
CS150 Introduction to Computer Science 1
Exercise Solution First questions What's output What's input
Python Basics with Jupyter Notebook
JavaScript: Introduction to Scripting
Basic Lessons 5 & 6 Mr. Kalmes.
Input and Output Python3 Beginner #3.
Basic Mr. Husch.
Formatting Output.
CS 1111 Introduction to Programming Spring 2019
Lecture 7 – Unit 1 – Chatbots Python – For loops + Robustness
3.3 – Invoke Workflow File Exercise 3.2: Extract as Workflow
Presentation transcript:

Review

Print Challenge Bruce asked, “When was the last time you had fish?” Now try these: Bruce asked, “When was the last time you had fish?” He’s leading an FEA group. FEA stands for “Fish Eater’s Anonymous.”

Printing variables You can print the data that is stored within a variable by passing the variable as an argument into the print function name = “Donald” name = “Donald” print (name) print (“Hello, my name is”, name) >> Donald >> Hello, my name is Donald

Changing variables Variables are called variables because the data stored in them can be changed You can change the value/data stored in a variable with a second assigning statement dollars = 19.99 print (“I have”, dollars, “in my account”) dollars = 10000.99 print (“Now, I have”, dollars, “in my account”)

Multiple Assignments You can assign multiple variables on the same line: x, y, z = 1, 2, 3 # the variables will assume the values in order You can also assign the same value to multiple variables x = y = z = 10 # variables x, y, and z will all hold the value of 10

Practice You’re working on a simple inventory management system for a small store. You’d like to store the name and price of two products and print them, so that your inventory page looks something like this: Item: Bread, price: $ 1.99 Item: Eggs, price: $ 3.49

Let’s make our programs more interactive! Input Function Let’s make our programs more interactive!

Reading input from the user So far, we have learned how to: OUTPUT information (print function) STORE information (variables) Now, we will learn how to get INPUT from the user, via the keyboard

Input Function You can make your programs interactive by asking the user to input some sort of information, using the input( ) function Notice that again, this keyword has a set of parentheses for an argument This means we CAN use the word input as a variable name

Input Function input ( ) has the same function as print ( ) , in that, they output whatever argument is passed into the function However, the input function only accepts one argument

Input Function The program will wait for the user to enter a response and continue to run the program when the user hits ENTER (in other words, the input function will cause a pause in the execution of your program) WARNING: You must store the data SOMEWHERE! (in a variable)

Input Function Example: username = input (“What is your username?: ” ) print (“Welcome,”, username, “!”) >> What is your username?: Donald >> Welcome, Donald !

Input function The input ( ) will always “return” a string This means that its output will always be treated as a string, as well as when it is stored in a variable price = input (“Give me a number:”) new_price = price+ 2 print (new_price)

Input function The input ( ) will always “return” a string This means that its output will always be treated as a string, as well as when it is stored in a variable price = input (“Give me a number:”) new_price = price + 2 # you are trying to add a string to an integer value print (new_price) # this will run an error because you added two values that were not the same type

Input function (Solution) price = input (“Give me a number:”) new_price = price + “2” print (new_price) >> Give me a number: 43 >> 432

Let’s try it again This time, using the input function, ask the user for the name and price of two products and print out a similar inventory for your store: Item: bread, Price: $ 15.99 Item: orange juice, Price: $ 34.67

Programming Challenge Write a program that allows the user to enter in their first name, and then their last name. Then, greet the user with a welcome message. First Name: Donald Last Name: Seok Welcome, Donald Seok !

Let’s have a little fun … Name a place: Another place A verb: A type of plant: An object: A color: An adjective: A type of weather: A feeling:

Mad Lib Exercise