COSC 235: Programming and Problem Solving Ch. 2: Your first programs!!! Instructor: Dr. X
Goals Understand Input Process Output (IPO) Use variables Understand expressions Use and understand iteration 2
Software Development Process Analyze Problem – what? Determine Specs - IO Create Design – how? Implement – make it Test/Debug – break it Maintain - …
Software Development Process
Program Elements Names Expressions Input/Output
Names Make them meaningful (descriptive) Camel case Use _ to connect two words Beware! – Symbols – Keywords – Case sensitive
Expressions Calculate new values Evaluate right hand side Assign to left! Spaces: are they important?
Output first… because it is easier Syntax print(,, …, ) print() Semantics: display information (data)
Input is a little tougher… Syntax = input( ) = eval(input( )) Semantics?
Assignment Syntax = Semantics? Have we seen this before?
Simultaneous assignment Syntax,, …, =,, …, Exercise: Write a sequence of assignment statements that exchange the values of thing1 & thing2
Exercise Print “Hello world” 10 times, then print it 100 times… Print the integer numbers from 0..10,
Loops org/wikipedia/commons/ thumb/f/f4/Shockwave_c oaster_sfot.jpg/220px- Shockwave_coaster_sfot.j pg eYwYLrlLWZs/UNlpG3goYgI/AAAA AAAACaI/MdQ2- CPcJYY/s1600/01.gif ookie.net/__cb /logopedi a/images/0/0a/Froot _Loops_logo.jpg
Loops Syntax for in : Semantics: avoid doing repetitive things using copy paste =) OR execute a definite sequence of steps
References “Python Programming: An Introduction to Computer Science”, 2 nd ed., John M. Zelle