1 / 5

Intro to Python

Python Lab #1. 1. Intro to Python. Adriane Huber Debbie Bartlett. Python Lab #1. 2. Python. Named derived from TV series, Monty Python’s Flying Circus, not the snake Important goal of developers was to make it fun Common practice was to make Monty Python references in example code

talor
Download Presentation

Intro to Python

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. Python Lab #1 1 Intro to Python Adriane Huber Debbie Bartlett

  2. Python Lab #1 2 Python • Named derived from TV series, Monty Python’s Flying Circus, not the snake • Important goal of developers was to make it fun • Common practice was to make Monty Python references in example code • Created by Guido Van Rossum in 1991 • Python is often compared to Tcl, Perl, Ruby, Scheme or Java • Why use Python? • General-purpose, interpreted high-level programming language • Design philosophy emphasizes code readability • Supports multiple programming paradigms • object-oriented and to a lesser extent functional • Can be used in a scripting or non-scripting context

  3. Python Lab #1 3 Sample Python Script def greet (): print (“Hello, World!”) name = input (“Enter your name:”) if name == “Debbie”: print (“Hello, Debbie! I am glad that you are in CS192 today!”) else: print (“Hello”, name) greet()

  4. Python Lab #1 4 Python Scripts • Creating a Python Script • Use a text editor such as gedit • Name the file greet.py • Write your script in greet.py • Save greet.py • To run python program in terminal window, type: • Python3.3 greet.py

  5. Python Lab #1 5 Python Lab1 Assignment • Type your own version of the python script • What happens if you • don’t use quotes around the first print statement? • Take them off, try it, then put them back • delete the tab in front of the first print statement? • Try it, put it back • remove the colon at the end of the first statement that begins with def? • Try it, put it back • Ask another question in your script • Google a “while loop” • Add a while loop to your Python Script • Show your script to a lab instructor or helper

More Related