Python 12 Mr. Husch.

Slides:



Advertisements
Similar presentations
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Advertisements

CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Getting Input in Python Assumes assignment statement, typecasts.
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.
Introduction to Python: Slides Referenced in Homework 0 CSE-391: Artificial Intelligence University of Pennsylvania Matt Huenerfauth January 2005.
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
Python File Handling. In all the programs you have made so far when program is closed all the data is lost, but what if you want to keep the data to use.
Documentation and Comments. What’s a comment? A comment is a simple form of documentation. Documentation is text that you the programmer write to explain.
Games Development 2 Review & Revision Strategy CO3301 End of Semester 1.
Python Let’s get started!.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
PHP Form Processing * referenced from
Introduction to Literate Programming in Matlab 2WN50 – Week programming-in-matlab.pptx?dl=0.
Today… Python Keywords. Iteration (or “Loops”!) Winter 2016CISC101 - Prof. McLeod1.
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
JUST BASIC Lessons 6 – 9 Mr. Kalmes.
Python 23 Mr. Husch.
Games Programming in Scratch
Python Lesson 12 Mr. Kalmes.
Madlib-Input, Strings, and Lists in Scratch
Python Let’s get started!.
Python 14 Mr. Husch.
Topics Introduction to Repetition Structures
Games Development 2 semester 1 Review & Revision
Think What will be the output?
Retrieving information from forms
Python Lesson 12 Mr. Kalmes.
Intro to PHP & Variables
English I Pre-AP Writing Notebook
Python 18 Mr. Husch.
Learning to Program in Python
Python 17 Mr. Husch.
Python Mr. Husch.
File Handling Programming Guides.
Topics Introduction to File Input and Output
CS005 Introduction to Programming
Python Lessons 13 & 14 Mr. Kalmes.
Lesson 2: Input and Variables
Passing Parameters by value
Loops CIS 40 – Introduction to Programming in Python
Coding Concepts (Basics)
Python 21 Mr. Husch.
Python 17 Mr. Husch.
Writing Functions( ) (Part 4)
Writing Functions( ) (Part 4)
Python 19 Mr. Husch.
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
ICT Gaming Lesson 3.
Python Lesson’S 1 & 2 Mr. Kalmes.
CSCI N207 Data Analysis Using Spreadsheet
Lab 4: Introduction to Scripting
Python 16 Mr. Husch.
Introduction to Python
Python Inputs Mr. Husch.
Python Lessons 13 & 14 Mr. Husch.
Python 16 Mr. Husch.
Python 19 Mr. Husch.
Python Lessons 7 & 8 Mr. Husch.
Python 10 Mr. Husch.
Python 18 Mr. Husch.
Python 4 and 5 Mr. Husch.
Python 13 Mr. Husch.
Basic 9 Mr. Husch.
Topics Introduction to File Input and Output
Variables, Constants, Assign.
Lecture 20 – Practice Exercises 4
Lecture 20 – Practice Exercises 4
Retrieving information from forms
Presentation transcript:

Python 12 Mr. Husch

Overview In this exercise we will cover one more input method you can use to pass variables to a script (script being another name for your .py files)

Name this code lastname12

Explanation On line 1 we have what's called an "import". This is how you add features to your script from the Python feature set. Rather than give you all the features at once, Python asks you to say what you plan to use. This keeps your programs small, but it also acts as documentation for other programmers who read your code later.

explanation The argv is the "argument variable", a very standard name in programming, that you will find used in many other languages. This variable holds the arguments you pass to your Python script when you run it. In the exercises you will get to play with this more and see what happens.

explanation Line 3 "unpacks" argv so that, rather than holding all the arguments, it gets assigned to four variables you can work with: script, first, second, and third. This may look strange, but "unpack" is probably the best word to describe what it does. It just says, "Take whatever is in argv, unpack it, and assign it to all of these variables on the left in order."

Test it Call your program in CMD and test that you can recall the script. Recall by: python programname.py first 2nd 3rd

Turn it in