Python Lessons 13 & 14 Mr. Kalmes.

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING Task 1 LEVEL 6 PROGRAMMING: Be able to use a text based language like Python and JavaScript & correctly use procedures and functions.
Advertisements

Programming Batch Files Aim: To introduce the concept of Batch processing and programming techniques. Lesson Outcomes  The need for Batch Processing.
Game Programming © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line L.
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.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Make a dice challenge! This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.Copy the code below in.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Getting Started With Python Brendan Routledge
Make a function This is a starter activity and should take 5 minutes [ slide 1 ] >>> def count(number): n=1 while n
PYTHON PROGRAMMING Year 9. Objective and Outcome Teaching Objective Today we will look at conditional statements in order to understand how programs can.
JUST BASIC Lessons 6 – 9 Mr. Kalmes.
Whatcha doin'? Aims: To start using Python. To understand loops.
A Playful Introduction to Programming by Jason R. Briggs
Python Lesson 12 Mr. Kalmes.
Repetition Structures
Python 14 Mr. Husch.
Python Lesson 12 Mr. Kalmes.
Engineering Innovation Center
Python 18 Mr. Husch.
Python Lesson 6 Mr. Kalmes.
Objective: Be able to add and subtract directed numbers.
Python 17 Mr. Husch.
Python Lesson 3 Mr. Kalmes.
Python I/O.
Python Mr. Husch.
Python Lessons 9 & 10 Mr. Kalmes.
Teaching London Computing
Task 1 Computer Programming LEVEL 6 PROGRAMMING:
Java Lesson 36 Mr. Kalmes.
Python Lesson 21 Mr. Kalmes.
Python 21 Mr. Husch.
Java Lesson 35 Mr. Kalmes.
Just Basic Lessons Mr. Kalmes.
Python 17 Mr. Husch.
Python Lessons 9 & 10 Mr. Husch.
Starter answer these questions in your book
Python 19 Mr. Husch.
Introduction In today’s lesson we will look at: why Python?
Just Basic Lesson 17 Part 1 Mr. Kalmes.
Just Basic Lessons 14 Mr. Kalmes.
Game Over Module 4 Lesson 2.
Python Lesson’S 1 & 2 Mr. Kalmes.
What is x? x = 12 %
Friday 8th November Mr Nicholls
Just Basic Lesson 15 Mr. Kalmes.
Python 16 Mr. Husch.
Just Basic Lessons Mr. Kalmes.
Basic Lessons 5 & 6 Mr. Kalmes.
Just Basic Lesson 12 Mr. Kalmes.
Just Basic Lessons 9 Mr. Kalmes.
Just Basic Lesson 19 Mr. Kalmes.
6 Figure Grid References
Input and Output Python3 Beginner #3.
Introduction to Python
Python Lessons 7 & 8 Mr. Kalmes.
Python Inputs Mr. Husch.
Python Lessons 13 & 14 Mr. Husch.
Java Lessons Mr. Kalmes.
Basic Mr. Husch.
Python 16 Mr. Husch.
Python 19 Mr. Husch.
Python 10 Mr. Husch.
Just Basic Lesson 13 Mr. Kalmes.
Objective: Be able to add and subtract directed numbers.
Python 18 Mr. Husch.
Python 12 Mr. Husch.
Python 13 Mr. Husch.
L L Line CSE 420 Computer Games Lecture #3 Introduction to Python.
Just Basic Lessons 7 Mr. Kalmes.
Just Basic Lessons 8 Mr. Kalmes.
Presentation transcript:

Python Lessons 13 & 14 Mr. Kalmes

Aims I will be able to create code that allows user inputs in the command prompt I will be able use the read command to open a file in the cmd prompt

Lesson 13

DO Now Recreate this program & save as lesson13.py

Lesson 13 Activity You need to test the original program and then add 5 more questions for a total of 8 and print out all the answers in a paragraph in the end. Please turn this in when you are done.

Lesson 14

Special Notice PLEASE BE CAUTIOUS, WORKING WITH FILES CAN BE AN EASY WAY TO ERASE YOUR WORK COMPLETELY *********************

Create the following Programs Save this at lesson141 Save this at lesson142

Things to look at Line 1-3 should be a familiar use of argv to get a filename. Next we have line 5 where we use a new command open. Right now, run pydoc open and read the instructions. Notice how like your own scripts and raw_input, it takes a parameter and returns a value you can set to your own variable. You just opened a file. Line 7 we print a little line, but on line 8 we have something very new and exciting. We call a function on txt. What you got back from open is a file, and it's also got commands you can give it. You give a file a command by using the . (dot or period), the name of the command, and parameters. Just like with open and raw_input. The difference is that when you say txt.read() you are saying, "Hey txt! Do your read command with no parameters!"

Run Your Program To run this in CMD you need to go to your folder directory that you saved the game in. You need to type in lesson142.py lesson141.py This will open both files, with 141 opening up inside 142.

This is what you should see Here's your file 'lesson14_sample.txt': This is stuff I typed and it’s very cool. Type the filename again: > ex15_sample.txt

Making comments Before turning in your work you need to make comments to lesson 142. To make a comment use the # symbol. Write what each line of code does.

Exit Slip What word do you need to type in user inputs What type of file do you need to be able to read it in python