90 likes | 210 Vues
In this lab session, led by second-year graduate student Linger (Tian Xu), attendees explored basic programming concepts using Python 2.6. The focus was on getting familiar with the IDLE environment, learning about shells and scripts, and understanding the print function. Students were introduced to writing comments, the concept of functions, and handling errors. Example scripts were provided for practical understanding. For continuous learning, resources will be shared via email and a dedicated website will be established for easy access to materials.
E N D
Course A201:Introduction to Programming 09/09/2010
Lab Instructor • Linger(TianXu), second year graduate student • joint degree of Computer Science and Cognitive science • Multisensory Lab directed by Prof. Chen Yu • E-mail: txu@indiana.edu
Special Note! • From now on • Better for you, better for us
Recap • Textbook Chapter 1 to 2 • Get familiar with IDLE designed for python • Know what’s shell, what’s a script • How to print out something by using function ‘print’ • Write comments • What is the concept of ‘function’, can I write one? (more on this in the future) • When error happens, how can I deal with it?
Recap • See the example script -> • This week I will Email you all the example script or slides I used in labs, next I will set up a website you can access all the materials. However, I will mostly use the slides you see in the lecture to avoid redundancy
This week • Let’s open IDLE • Python version 2.6 installed instead of 3.1 • Add this line in the very beginning: from __future__ import print_function, division • Using input will give you an error, use raw_input instead
This week [functions] Ex: radius = float(raw_input(‘Radius: ’)) • This is a combination of two functions: radius = raw_input (‘Radius: ’) # radius now contains a string value radius = float(radius) # radius now contains a float value • Execute this function first
This week • From inside to outside [functions] Ex: radius = float(raw_input(‘Radius: ’)) • This is a combination of two functions: radius = raw_input (‘Radius: ’) # radius now contains a string value radius = float(radius) # radius now contains a float value • Then do the type conversion
Have a nice evening! • See you next time~