Presentation is loading. Please wait.

Presentation is loading. Please wait.

Python Lesson 12 Mr. Kalmes.

Similar presentations


Presentation on theme: "Python Lesson 12 Mr. Kalmes."— Presentation transcript:

1 Python Lesson 12 Mr. Kalmes

2 Aims You will be able to open a python file using the CMD prompt

3 Recreate the following Save as Python12.py in your python folder

4 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.

5 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.

6 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."

7 CMD Prompt What is the CMD Prompt?
Command Prompt is a command line interpreter application available in most Windows operating systems. Command Prompt is used to execute entered commands. Most of those commands are used to automate tasks via scripts and batch files, perform advanced administrative functions, and troubleshoot and solve certain kinds of Windows issues.

8 CMD Prompt What is the CMD Prompt? Step 1: Hold down windows key and R
Step 2: Type in CMD and hit enter

9 CMD Prompt How to Use CMD Prompt
DIR: This will allow you to see what is available CD + Filename: This allows you to access file from directory CD/: This takes you back to your C: Drive CD .. : This takes you back one step

10 Access your Python File
Step 1: access the command prompt Step 2: Type in CD Desktop If you want to see all of your options type in dir Step 3: Type in CD Python Step 4: Type in python Python12.py apples oranges bananas

11 Lesson 12 Assignment Your assignment for today is to add to the code and have a total of 6 variables. Once you are done test it and turn it in to the drop box. Once it is turned in please answer the exit slip questions and work on any make up work you may have.

12 Exit Slip Questions What are the steps to access the CMD Prompt
What does import do? What does Argv do?


Download ppt "Python Lesson 12 Mr. Kalmes."

Similar presentations


Ads by Google