1 / 24

Welcome to programming!

Welcome to programming!. Python Lesson one :set up /IDLE interface/print / command. What is python?.

drew
Download Presentation

Welcome to programming!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Welcome to programming! Python Lesson one :set up /IDLE interface/print / command

  2. What is python? • Python is a powerful object-oriented programming language that can be used in a wide variety of applications. Python is one of the family of 'P' languages widely used in web development, Python, Perl, PHP. Examples of Python applications: • Web Development (CGI scripts, Content Management Systems) • Database Access • Desktop GUIs (windows) • Scientific and Numeric Computing • Low Level Network Programming • Software Development • Games and 3D Graphics

  3. Lesson one-print and command Today we are going to use the most basic of features print and command. Print will put information on a page

  4. Open up python Go to your program tree Open up python 2.5 Open up the IDLE(pythons GUI) The reason that we are doing this is that we need to open up the user interface(GUI)

  5. What the GUI looks like This is where you type your programming into This is also where you run your program

  6. Setting up Python We are going to open up python You should have selected IDLE to open up the user interface Save a python file to your documents making sure the end of the file is named .py Save your python file as Test.py

  7. Open up a new window Go to file –new window Your programming window will now open up

  8. print Type print command Print “this is a python string!” Now press the f5 key to run your first program When you run your program it shows the results in your GUI

  9. Lesson two-user input Empty content of the previous program so it looks now like this What we are going to do is type in some new code, that will require an INPUT Type in the following code: You need to now run this program you have written by pressing f5

  10. User input continued… Once you have selected f5 it will prompt you to save.so save as user input.py When you press f5 your program will open up in the interface and it will prompt you to enter a number

  11. User input continued….. Now you have run your program it prompts you to enter a value in numbers Enter your age then press enter-it will then tell you how old you are!

  12. Conditional statements-if statement “If age is bigger than 60 then print your are quite old” Delete all previous code And type in the following code Then press f5 to run it-save it as use of conditional statements.py

  13. Your program once run will look like this

  14. Using else statement Delete your prior programs and type in the following program Notice now we are using elseas well as if • When you type in an age above 60 you will get a message telling you ,you are old • When you type in an age below 60 you will get a message telling you ,you are not that old

  15. Looping….. Open up IDLE-select file then new Type in the following code Then press f5 This will then print the numbers 1-10

  16. Looping cont…. To extend this we are going to type in this additional code to create a second line of data This printed one line of numbers 1-10 Now we are going to get python to print a second line of data

  17. Looping……. The result of this is………….. Two sets of data Change the number at the end of the code to 2 and see the effect

  18. Looping……. Now to get python to print squared numbers Go to your previous window that looks like this…. Instead of the 0 type in o to get python to print squared numbers

  19. This is what it looks like Now you have a squared list of data So –for ? In range(*enter parameter*) * what you want to be looped

  20. Extension task-looping This will create a list of data with next to each number description as to if it is odd or even To see effect check next slide

  21. What the lists look like Now you can see the label

  22. How to use functions in python You need to type in the following code exactly ,and make sure that you have same spaces-EXACTLY EXPLANATION: YOU NEED TO DEFINE THE NUMBER YOU ARE GOING TO SQUARE=X

  23. Project 1-pass word reminder You are now going to create a program to make sure that you create a program and that the password you have selected

More Related