* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download www.cs.colostate.edu
C Sharp syntax wikipedia , lookup
String literal wikipedia , lookup
Functional programming wikipedia , lookup
Indentation style wikipedia , lookup
Structured programming wikipedia , lookup
Falcon (programming language) wikipedia , lookup
Go (programming language) wikipedia , lookup
AppleScript wikipedia , lookup
Object-oriented programming wikipedia , lookup
C Sharp (programming language) wikipedia , lookup
Control flow wikipedia , lookup
P 1 y t h o n L a b # 1 Intro to Python Adriane Huber Debbie Bartlett P 2 y t h o n L a b # 1 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 P 3 y t h o n L a b # 1 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() P 4 y t h o n L a b # 1 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: lpython3.3 greet.py P 5 y t h o n L a b # 1 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