Presentation is loading. Please wait.

Presentation is loading. Please wait.

UW CSE 140 Section 1/10, Winter 2013. Find partners! Group can be 2-4 people. Try to share as much as possible about what you think with your teammates!

Similar presentations


Presentation on theme: "UW CSE 140 Section 1/10, Winter 2013. Find partners! Group can be 2-4 people. Try to share as much as possible about what you think with your teammates!"— Presentation transcript:

1 UW CSE 140 Section 1/10, Winter 2013

2

3 Find partners! Group can be 2-4 people. Try to share as much as possible about what you think with your teammates!

4 Create an empty text file and save everything about what you try and what you get. You can also include your name and your teammate’s name in the file. Email this text file to TA after class if you still feel doubt about any part of the section.

5 Command Prompt in Windows Terminal in Mac/Linux

6 Show current directory/folder – pwd (on unix, linux, osx) – echo %cd% (on windows) List contents in the current directory/folder – ls (on unix, linux, osx) – dir (mostly only on windows) / on unix, linux, osx \ on windows

7 Change directory – cd Use “tab” to loop through path! Make directory – mkdir (on unix, linux, osx) – md (on windows)

8 Using interpreter Using script – python myprogram.py – python myprogram.py argument1 argument2 The operating system command shell/prompt is not the same as the Python interpreter

9 Create a table using print about the simple info of your team. The required variable fields are: First name, Last name, Month of birth in number, and Favorite color. Your code should start with: first_name = “Michael” last_name = “Ernst”... Example output: ”Michael Ernst, 1, likes green" "Dun-Yu Hsiao, 5, likes red"

10 Careful about the conversion between number and string Use str(some number)

11 Testing your program Making a speed conversion chart mph->kph – Chart the conversion: 10, 30, 40, 60, 75, 100mph – Print out example: 10mph 16.09kph... (Tedious, isn’t it?)

12 Use loop to reduce code repetition! For loop: for iterating_var in sequence: statements(s) for x in [ 10, 2, 43]: print( x )

13 s = 0 for x in [ 10, 2, 43]: s = s + x Equivalent to: s = 0 x = 10 s = s + x x = 2 s = s + x x = 43 s = s + x

14 s = 0 for x in [ 5, 6 ]: for y in [ 7, 8 ]: s = s + x + y Equivalent to: s = 0 x = 5 for y in [ 7, 8 ]: s = s + x + y x = 6 for y in [ 7, 8 ]: s = s + x + y s = 0 x = 5 y = 7 s = s + x + y y = 8 s = s + x + y x = 6 y = 7 s = s + x + y y = 8 s = s + x + y

15

16 Making a speed conversion chart mph->kph – Chart the conversion: 10, 30, 40, 60, 75, 100mph – Print out example: 10mph 16.093kph Now try it using one for loop! Much more concise!

17 Numbers: 1, 2, 4, 8, 10, 20, 40, 80, 100, 200, 400, 800, 1000 Import - To not reinvent the wheel! - Use the console to check usage quickly!

18 Don’t forget colon Careful about the indentation

19

20 Command line environment Print Loop


Download ppt "UW CSE 140 Section 1/10, Winter 2013. Find partners! Group can be 2-4 people. Try to share as much as possible about what you think with your teammates!"

Similar presentations


Ads by Google